class Blinkman::Bot
Constants
- LED_COLORS
Attributes
handlers[R]
Public Class Methods
new(&block)
click to toggle source
# File lib/blinkman/bot.rb, line 14 def initialize(&block) Dotenv.load ::Bundler.require(:default) @adapter = Adapter.adapter_classes.last.new(self) @handlers = [] instance_eval(&block) if block end
Public Instance Methods
listen()
click to toggle source
# File lib/blinkman/bot.rb, line 22 def listen @adapter.listen end
on_receive(message)
click to toggle source
# File lib/blinkman/bot.rb, line 26 def on_receive(message) selected_handler = handlers.find { |handler| handler.event.match?(message) } selected_handler.action.invoke if selected_handler end
Private Instance Methods
blink(handler)
click to toggle source
# File lib/blinkman/bot.rb, line 33 def blink(handler) @handlers.push(handler) end
during(millisec)
click to toggle source
# File lib/blinkman/bot.rb, line 51 def during(millisec) millisec end
led(color_code, times, during, event)
click to toggle source
# File lib/blinkman/bot.rb, line 44 def led(color_code, times, during, event) Handler.new( Action.new(color_code, times, during), event ) end
when_if(&block)
click to toggle source
# File lib/blinkman/bot.rb, line 55 def when_if(&block) Event.new(&block) end