Class: Del::Robot
- Inherits:
-
Object
- Object
- Del::Robot
- Defined in:
- lib/del/robot.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#rooms ⇒ Object
readonly
Returns the value of attribute rooms.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
-
#initialize(configuration:) ⇒ Robot
constructor
A new instance of Robot.
- #receive(message) ⇒ Object
- #run ⇒ Object
- #send_message(jid, message) ⇒ Object
Constructor Details
#initialize(configuration:) ⇒ Robot
Returns a new instance of Robot.
5 6 7 8 9 10 11 12 13 |
# File 'lib/del/robot.rb', line 5 def initialize(configuration:) @users = UserRepository.new @rooms = RoomRepository.new @connection = Connection.new( configuration: configuration, users: users, rooms: rooms, ) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/del/robot.rb', line 3 def connection @connection end |
#rooms ⇒ Object (readonly)
Returns the value of attribute rooms.
3 4 5 |
# File 'lib/del/robot.rb', line 3 def rooms @rooms end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
3 4 5 |
# File 'lib/del/robot.rb', line 3 def users @users end |
Instance Method Details
#receive(message) ⇒ Object
22 23 24 25 |
# File 'lib/del/robot.rb', line 22 def receive() return if .type == :error || .body.nil? (.from, .body) end |
#run ⇒ Object
15 16 17 18 19 20 |
# File 'lib/del/robot.rb', line 15 def run connection.connect(self) sleep rescue Interrupt connection.disconnect end |
#send_message(jid, message) ⇒ Object
27 28 29 |
# File 'lib/del/robot.rb', line 27 def (jid, ) connection.deliver(jid, ) end |