Class: Ruboty::Robot
Constant Summary collapse
- DEFAULT_ENV =
"development"
- DEFAULT_ROBOT_NAME =
"ruboty"
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #brain ⇒ Object
-
#initialize(options = {}) ⇒ Robot
constructor
A new instance of Robot.
-
#name ⇒ Object
ROBOT_NAME is deprecated.
- #receive(attributes) ⇒ Object
- #run ⇒ Object
- #say(*args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Robot
Returns a new instance of Robot.
12 13 14 |
# File 'lib/ruboty/robot.rb', line 12 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/ruboty/robot.rb', line 10 def @options end |
Instance Method Details
#brain ⇒ Object
48 49 50 |
# File 'lib/ruboty/robot.rb', line 48 def brain Brains::Base.find_class.new end |
#name ⇒ Object
ROBOT_NAME is deprecated.
44 45 46 |
# File 'lib/ruboty/robot.rb', line 44 def name ENV["RUBOTY_NAME"] || ENV["ROBOT_NAME"] || DEFAULT_ROBOT_NAME end |
#receive(attributes) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/ruboty/robot.rb', line 27 def receive(attributes) = Message.new(attributes.merge(robot: self)) unless handlers.inject(false) { |matched, handler| matched | handler.call() } handlers.each do |handler| handler.call(, missing: true) end end end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruboty/robot.rb', line 16 def run daemon dotenv bundle setup pid remember handle adapt end |
#say(*args) ⇒ Object
38 39 40 41 |
# File 'lib/ruboty/robot.rb', line 38 def say(*args) adapter.say(*args) true end |