class Ellen::Robot

Constants

DEFAULT_ROBOT_NAME

Attributes

options[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/ellen/robot.rb, line 11
def initialize(options = {})
  @options = options
end

Public Instance Methods

brain() click to toggle source
# File lib/ellen/robot.rb, line 35
def brain
  Brains::Base.find_class.new
end
name() click to toggle source
# File lib/ellen/robot.rb, line 31
def name
  ENV["ROBOT_NAME"] || DEFAULT_ROBOT_NAME
end
receive(attributes) click to toggle source
# File lib/ellen/robot.rb, line 24
def receive(attributes)
  message = Message.new(attributes.merge(robot: self))
  handlers.each do |handler|
    handler.call(message)
  end
end
run() click to toggle source
# File lib/ellen/robot.rb, line 15
def run
  dotenv
  bundle
  setup
  remember
  handle
  adapt
end

Private Instance Methods

adapt() click to toggle source
# File lib/ellen/robot.rb, line 42
def adapt
  adapter.run
end
adapter() click to toggle source
# File lib/ellen/robot.rb, line 46
def adapter
  AdapterBuilder.new(self).build
end
bundle() click to toggle source
# File lib/ellen/robot.rb, line 51
def bundle
  Bundler.require
end
dotenv() click to toggle source
# File lib/ellen/robot.rb, line 55
def dotenv
  Dotenv.load if options[:dotenv]
end
handle() click to toggle source
# File lib/ellen/robot.rb, line 72
def handle
  handlers
end
handlers() click to toggle source
# File lib/ellen/robot.rb, line 63
def handlers
  Ellen.handlers.map {|handler_class| handler_class.new(self) }
end
remember() click to toggle source
# File lib/ellen/robot.rb, line 68
def remember
  brain
end
setup() click to toggle source
# File lib/ellen/robot.rb, line 59
def setup
  load(options[:load]) if options[:load]
end