Class: Ellen::Message
- Inherits:
-
Object
- Object
- Ellen::Message
- Defined in:
- lib/ellen/message.rb
Instance Attribute Summary collapse
-
#match_data ⇒ Object
readonly
Returns the value of attribute match_data.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #body ⇒ Object
- #from ⇒ Object
-
#initialize(original) ⇒ Message
constructor
A new instance of Message.
- #match(pattern) ⇒ Object
- #reply(body, options = {}) ⇒ Object
- #robot ⇒ Object
- #to ⇒ Object
Constructor Details
#initialize(original) ⇒ Message
Returns a new instance of Message.
8 9 10 |
# File 'lib/ellen/message.rb', line 8 def initialize(original) @original = original end |
Instance Attribute Details
#match_data ⇒ Object (readonly)
Returns the value of attribute match_data.
3 4 5 |
# File 'lib/ellen/message.rb', line 3 def match_data @match_data end |
Instance Method Details
#[](index) ⇒ Object
32 33 34 |
# File 'lib/ellen/message.rb', line 32 def [](index) match_data[index] end |
#body ⇒ Object
12 13 14 |
# File 'lib/ellen/message.rb', line 12 def body @original[:body] end |
#from ⇒ Object
16 17 18 |
# File 'lib/ellen/message.rb', line 16 def from @original[:from] end |
#match(pattern) ⇒ Object
28 29 30 |
# File 'lib/ellen/message.rb', line 28 def match(pattern) @match_data = pattern.match(body) end |
#reply(body, options = {}) ⇒ Object
36 37 38 39 |
# File 'lib/ellen/message.rb', line 36 def reply(body, = {}) attributes = { body: body, from: to, to: from, original: original }.merge() robot.say(attributes) end |
#robot ⇒ Object
20 21 22 |
# File 'lib/ellen/message.rb', line 20 def robot @original[:robot] end |
#to ⇒ Object
24 25 26 |
# File 'lib/ellen/message.rb', line 24 def to @original[:to] end |