0

I have seen it before but I cannot remember where. I have a Ruby program that I'd like to execute and interact with in command line and call the functions. Similar to irb but within that program. For example:

class Message
 @@messages_sent = 0
 def initialize (from, to)
 @from = from
 @to = to
 @@messages_sent +=1
 end 
end
class Email < Message
 def initialize (from,to)
 super
 end
end

and I want to run the script and call functions such as

my_message = Message.new('NYC','TDOT') 

How? I did the ruby myprogram.rb and just runs it and closes it, I actually want to enter into the program

asked Mar 29, 2014 at 5:26

1 Answer 1

1

You need to first require IRB and then type IRB.start where you want to start it:

require 'irb'
IRB.start
answered Mar 29, 2014 at 5:32

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.