On Thu, Jan 27, 2011 at 2:31 AM, Priya D. <li...@ruby-forum.com> wrote:
> I'm creating a new object for a class using irb. At that time, if the > object is created successfully, a new console should be open. The newly > opened console should act as the created object. > > so that i can execute all the instance methods through the newly opened > console, without prefixing object to the methods. > > am i clear? > > The concept of nested irb shells is already supported by irb. You merely have to use the method "irb <instance>" while in irb to insert yourself into the instance's namespace. irb(main):001:0> class Test irb(main):002:1> def test_method irb(main):003:2> "test method called correctly" irb(main):004:2> end irb(main):005:1> end => nil irb(main):006:0> irb Test.new irb#1(#<Test:0x1c67478>):001:0> test_method => "test method called correctly" irb#1(#<Test:0x1c67478>):002:0> quit => #<IRB::Irb: @scanner=#<RubyLex:0x1bac510>, @context=#<IRB::Context:0x1bacbc8>, @signal_status=:IN_EVAL> irb(main):007:0> quit bash% Josh -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.