Class: Del::Message
- Inherits:
-
Object
- Object
- Del::Message
- Defined in:
- lib/del/message.rb
Overview
An XMPP Message
Constant Summary collapse
- PREFIX =
'/code'
Instance Attribute Summary collapse
-
#robot ⇒ Object
readonly
Returns the value of attribute robot.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #execute_shell(command) ⇒ Object
-
#initialize(text, robot:, source:) ⇒ Message
constructor
A new instance of Message.
- #reply(message) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(text, robot:, source:) ⇒ Message
Returns a new instance of Message.
9 10 11 12 13 |
# File 'lib/del/message.rb', line 9 def initialize(text, robot:, source:) @text = text @robot = robot @source = source end |
Instance Attribute Details
#robot ⇒ Object (readonly)
Returns the value of attribute robot.
7 8 9 |
# File 'lib/del/message.rb', line 7 def robot @robot end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/del/message.rb', line 7 def source @source end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/del/message.rb', line 7 def text @text end |
Instance Method Details
#execute_shell(command) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/del/message.rb', line 19 def execute_shell(command) reply("Okay, I'm on it!") ShellCommand.new(command).run do |line| if block_given? yield line else reply("#{PREFIX} #{line}") end end end |
#reply(message) ⇒ Object
15 16 17 |
# File 'lib/del/message.rb', line 15 def reply() source.reply(robot, ) end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/del/message.rb', line 30 def to_s "#{source}: #{text}" end |