class Ant::Bot::Adapter::Channel

This class simulates a message chat with a user.

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/ant/bot/adapters/debug.rb, line 32
def initialize(messages, name, echo)
  @state = :open
  @pending_messages = messages
  @name = name
  @echo = echo
end

Public Instance Methods

answer(message) click to toggle source

receives the answer from the bot

# File lib/ant/bot/adapters/debug.rb, line 67
def answer(message)
  send_data(message)
  @state = :open
end
echo=(toogle) click to toggle source
# File lib/ant/bot/adapters/debug.rb, line 62
def echo=(toogle)
  @echo = toogle
end
empty?() click to toggle source

Checks if there are still messages in the channel

# File lib/ant/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/ant/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/ant/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/ant/bot/adapters/debug.rb, line 55
def send_data(message)
  return unless @echo

  puts "Sending message to channel: #{@name}"
  puts message
end