Class: Rodbot::Simulator
- Inherits:
-
Object
- Object
- Rodbot::Simulator
- Defined in:
- lib/rodbot/simulator.rb
Overview
Simulate a chat client
Instance Method Summary collapse
-
#initialize(sender, raw: false) ⇒ Simulator
constructor
A new instance of Simulator.
- #run ⇒ Object
Constructor Details
#initialize(sender, raw: false) ⇒ Simulator
Returns a new instance of Simulator.
17 18 19 20 21 |
# File 'lib/rodbot/simulator.rb', line 17 def initialize(sender, raw: false) @sender, @raw = sender, raw @relay = Rodbot::Relay.new @pastel = Pastel.new end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/rodbot/simulator.rb', line 23 def run puts nil, "Talking to app on #{Rodbot::Services::App.url} as sender #{@pastel.inverse(@sender)}." puts 'Type commands beginning with "!" or empty line to exit.', nil while (line = Readline.readline("rodbot> ", true)) && !line.empty? puts nil, reply_to(line), nil end puts end |