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

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.