class Kybus::Bot::Adapter::Channel
This class simulates a message chat with a user.
Attributes
echo[W]
Public Class Methods
new(messages, name, echo)
click to toggle source
It is build from an array of raw messages, the name of the channel and the config to enable debug messages
# File lib/kybus/bot/adapters/debug.rb, line 32 def initialize(messages, name, echo) @state = :open @pending_messages = messages.dup @name = name @echo = echo end
Public Instance Methods
answer(message)
click to toggle source
receives the answer from the bot
# File lib/kybus/bot/adapters/debug.rb, line 65 def answer(message) send_data(message) @state = :open end
empty?()
click to toggle source
Checks if there are still messages in the channel
# File lib/kybus/bot/adapters/debug.rb, line 45 def empty? @pending_messages.empty? end
open?()
click to toggle source
Checks if there are messages open or that has not been answered
# File lib/kybus/bot/adapters/debug.rb, line 40 def open? @state == :open end
read_message()
click to toggle source
returns the next message in the buffer
# File lib/kybus/bot/adapters/debug.rb, line 50 def read_message @state = :closed DebugMessage.new(@pending_messages.shift, @name) end
send_data(message)
click to toggle source
# File lib/kybus/bot/adapters/debug.rb, line 55 def send_data(message) return unless @echo puts "Sending message to channel: #{@name}" puts message end