On Aug 25, 2010, at 10:50 AM, Quintus wrote:

> 1. I wanted to use IRB to just allow the user to enter Ruby code in =
the
> current project context, but IRB seems to only read from STDIN. I =
didn't
> find a possibility to direct IRB somewhere else. So, is there one or =
can
> I give up on this?

On Unix, you can use a Psuedo-Terminal (PTY) to manage an IRb process:

$ ruby pty_irb.rb=20
>> j =3D "james"
=3D> "james"
>> j.capitalize
=3D> "James"
>> exit
Cakey-Please:~/Desktop $ cat pty_irb.rb=20
require "pty"
require "expect"

PTY.spawn("irb -f --simple-prompt") do |reader, writer, pid|
 input =3D ""
 while output =3D reader.expect(/^>>\s+/)
   if output and output.first
     output.first.sub!(/\A#{Regexp.escape(input.to_s.rstrip)}\r?\n/, "")
   end
   print output
   $stdout.flush
   input =3D gets
   writer << input
 end
end

> A major part of this problems is that the code has to be
> platform-independent, because the GUI is going to be run on Windows =
and
> Linux systems (and maybe Macs as well)...

I don't think the PTY library works on Windows, unfortunately.  Perhaps =
there's a different  but similar strategy you can use there.

James Edward Gray II=