お試し:

 require "phi"
 
 p $stdin  #=> #<Phi::IOHook:0x12ed4c0>
 p $stdout #=> #<Phi::IOHook:0x12ed4c0>
 p $stderr #=> #<Phi::IOHook:0x12ed4c0>
 p STDIN   #=> #<IO:0x12fe860>
 p STDOUT  #=> #<IO:0x12fe848>
 p STDERR  #=> #<IO:0x12fe830>

----

http://jp.rubyist.net/magazine/?0002-Apollo

Apollo.exe では $stdin、$stdout、$stderr、$> の値は Phi::IO という定数値で、これは Phi::IOHook のインスタンスになっています。Phi::IOHook は IO のサブクラスです。Phi::IOHook は write、gets、getc、flush、close メソッドをオーバーライドしています。そのほかのメソッドは、内部でこれらのメソッドを呼び出します。例えば print は内部で write を呼び出します。

----

 require "phi"
 require "methods_for_wiki"
 puts Phi::IOHook.methods_for_wiki(nil)

!!! <<                    => [[IO#<<]]
!!! all?                  => [[Enumerable#all?]]
!!! any?                  => [[Enumerable#any?]]
!!! binmode
!!! close
!!! close_read            => [[ruby-man:IO]]#close_read
!!! close_read            => [[IO#close_read]]
!!! close_write           => [[IO#close_write]]
!!! closed?               => [[IO#closed?]]
!!! collect               => [[Enumerable#collect]]
!!! detect                => [[Enumerable#detect]]
!!! each                  => [[IO#each]]
!!! each_byte             => [[IO#each_byte]]
!!! each_line             => [[IO#each_line]]
!!! each_with_index       => [[Enumerable#each_with_index]]
!!! entries               => [[Enumerable#entries]]
!!! eof                   => [[IO#eof]]
!!! eof?                  => [[IO#eof?]]
!!! fcntl                 => [[IO#fcntl]]
!!! fileno                => [[IO#fileno]]
!!! find                  => [[Enumerable#find]]
!!! find_all              => [[Enumerable#find_all]]
!!! flush
!!! fsync                 => [[IO#fsync]]
!!! getc

 require "phi"
 print "hit key : "
 c = $stdin.getc
 print "\n"
 p c
 p c.chr
 p :ok


{{attach_view(getc.png)}}

!!! gets

 require "phi"
 print "input string ([ret] to end) : "
 c = $stdin.gets
 print "\n"
 p c
 p :ok



{{attach_view(gets.png)}}


!!! grep                  => [[Enumerable#grep]]
!!! include?              => [[Enumerable#include?]]
!!! inject                => [[Enumerable#inject]]
!!! inspect               => [[IO#inspect]]
!!! ioctl                 => [[IO#ioctl]]
!!! isatty                => [[IO#isatty]]
!!! lineno                => [[IO#lineno]]
!!! lineno=               => [[IO#lineno=]]
!!! map                   => [[Enumerable#map]]
!!! max                   => [[Enumerable#max]]
!!! member?               => [[Enumerable#member?]]
!!! min                   => [[Enumerable#min]]
!!! partition             => [[Enumerable#partition]]
!!! pid                   => [[IO#pid]]
!!! pos                   => [[IO#pos]]
!!! pos=                  => [[IO#pos=]]
!!! print                 => [[IO#print]]
!!! printf                => [[IO#printf]]
!!! putc                  => [[IO#putc]]



!!! puts                  => [[IO#puts]]
!!! read                  => [[IO#read]]
!!! readchar              => [[IO#readchar]]
!!! readline              => [[IO#readline]]
!!! readlines             => [[IO#readlines]]

 require "phi"
 puts "[ret] + Ctrl+D to end of input"
 s = $stdin.readlines
 p s

{{attach_view(1.png)}}

!!! reject                => [[Enumerable#reject]]
!!! reopen                => [[IO#reopen]]
!!! rewind                => [[IO#rewind]]
!!! seek                  => [[IO#seek]]
!!! select                => [[Enumerable#select]]
!!! sort                  => [[Enumerable#sort]]
!!! sort_by               => [[Enumerable#sort_by]]
!!! stat                  => [[IO#stat]]
!!! sync                  => [[IO#sync]]
!!! sync=                 => [[IO#sync=]]
!!! sysread               => [[IO#sysread]]
!!! sysseek               => [[IO#sysseek]]
!!! syswrite              => [[IO#syswrite]]
!!! tell                  => [[IO#tell]]
!!! to_a                  => [[Enumerable#to_a]]
!!! to_i                  => [[IO#to_i]]
!!! to_io                 => [[IO#to_io]]
!!! tty?                  => [[IO#tty?]]
!!! ungetc                => [[IO#ungetc]]
!!! write
!!! zip                   => [[Enumerable#zip]]

----

ご意見・ご質問{{comment}}