Class: Ellen::Robot

Inherits:
Object
  • Object
show all
Includes:
Mem
Defined in:
lib/ellen/robot.rb

Constant Summary collapse

DEFAULT_ROBOT_NAME =
"ellen"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Robot

Returns a new instance of Robot.



11
12
13
# File 'lib/ellen/robot.rb', line 11

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/ellen/robot.rb', line 9

def options
  @options
end

Instance Method Details

#brainObject



35
36
37
# File 'lib/ellen/robot.rb', line 35

def brain
  Brains::Base.find_class.new
end

#nameObject



31
32
33
# File 'lib/ellen/robot.rb', line 31

def name
  ENV["ROBOT_NAME"] || DEFAULT_ROBOT_NAME
end

#receive(attributes) ⇒ Object



24
25
26
27
28
29
# 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

#runObject



15
16
17
18
19
20
21
22
# File 'lib/ellen/robot.rb', line 15

def run
  dotenv
  bundle
  setup
  remember
  handle
  adapt
end