Class: Ant::Bot::Adapter::Channel
- Inherits:
-
Object
- Object
- Ant::Bot::Adapter::Channel
- Defined in:
- lib/ant/bot/adapters/debug.rb
Overview
This class simulates a message chat with a user.
Instance Method Summary collapse
-
#answer(message) ⇒ Object
receives the answer from the bot.
- #echo=(toogle) ⇒ Object
-
#empty? ⇒ Boolean
Checks if there are still messages in the channel.
-
#initialize(messages, name, echo) ⇒ Channel
constructor
It is build from an array of raw messages, the name of the channel and the config to enable debug messages.
-
#open? ⇒ Boolean
Checks if there are messages open or that has not been answered.
-
#read_message ⇒ Object
returns the next message in the buffer.
- #send_data(message) ⇒ Object
Constructor Details
#initialize(messages, name, echo) ⇒ Channel
It is build from an array of raw messages, the name of the channel and the config to enable debug messages
32 33 34 35 36 37 |
# File 'lib/ant/bot/adapters/debug.rb', line 32 def initialize(, name, echo) @state = :open @pending_messages = @name = name @echo = echo end |
Instance Method Details
#answer(message) ⇒ Object
receives the answer from the bot
67 68 69 70 |
# File 'lib/ant/bot/adapters/debug.rb', line 67 def answer() send_data() @state = :open end |
#echo=(toogle) ⇒ Object
62 63 64 |
# File 'lib/ant/bot/adapters/debug.rb', line 62 def echo=(toogle) @echo = toogle end |
#empty? ⇒ Boolean
Checks if there are still messages in the channel
45 46 47 |
# File 'lib/ant/bot/adapters/debug.rb', line 45 def empty? @pending_messages.empty? end |
#open? ⇒ Boolean
Checks if there are messages open or that has not been answered
40 41 42 |
# File 'lib/ant/bot/adapters/debug.rb', line 40 def open? @state == :open end |
#read_message ⇒ Object
returns the next message in the buffer
50 51 52 53 |
# File 'lib/ant/bot/adapters/debug.rb', line 50 def @state = :closed DebugMessage.new(@pending_messages.shift, @name) end |
#send_data(message) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/ant/bot/adapters/debug.rb', line 55 def send_data() return unless @echo puts "Sending message to channel: #{@name}" puts end |