B
Bertram Scharpf
Hi,
this may be easy to anwer but it is difficult to google for.
While developping I would like to play around with objects from
time to time. Just like this:
irb(main):001:0> class C ; def f ; "F" ; end ; end
=> nil
irb(main):002:0> irb C.new
irb#1(#<C:0xb7910d40>):001:0> f
=> "F"
irb#1(#<C:0xb7910d40>):002:0>
In common my classes are not so easy to type in. So, I would like
to call Irb from somewhere inside the application as I do here:
---->-call_irb.rb---------------
#!/usr/bin/ruby
class C
def f
"F"
end
end
if $0 == __FILE__ then
require "irb"
$c = C.new
IRB.start
end
----<---------------------------
and then
user@host $ ./call_irb.rb
irb(main):001:0> irb $c
irb#1(#<C:0xb7be4ee0>):001:0> f
=> "F"
irb#1(#<C:0xb7be4ee0>):002:0>
Is there a way how I can call C.new's Irb directly without doing
the long-winded definition of a global variable first? I already
examined the irb sources but this seems to be well-hidden to me.
Thanks in advance and Merry Christmas,
Bertram
this may be easy to anwer but it is difficult to google for.
While developping I would like to play around with objects from
time to time. Just like this:
irb(main):001:0> class C ; def f ; "F" ; end ; end
=> nil
irb(main):002:0> irb C.new
irb#1(#<C:0xb7910d40>):001:0> f
=> "F"
irb#1(#<C:0xb7910d40>):002:0>
In common my classes are not so easy to type in. So, I would like
to call Irb from somewhere inside the application as I do here:
---->-call_irb.rb---------------
#!/usr/bin/ruby
class C
def f
"F"
end
end
if $0 == __FILE__ then
require "irb"
$c = C.new
IRB.start
end
----<---------------------------
and then
user@host $ ./call_irb.rb
irb(main):001:0> irb $c
irb#1(#<C:0xb7be4ee0>):001:0> f
=> "F"
irb#1(#<C:0xb7be4ee0>):002:0>
Is there a way how I can call C.new's Irb directly without doing
the long-winded definition of a global variable first? I already
examined the irb sources but this seems to be well-hidden to me.
Thanks in advance and Merry Christmas,
Bertram