Class: Ellen::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/ellen/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_dataObject (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

#bodyObject



12
13
14
# File 'lib/ellen/message.rb', line 12

def body
  @original[:body]
end

#fromObject



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, options = {})
  attributes = { body: body, from: to, to: from, original: original }.merge(options)
  robot.say(attributes)
end

#robotObject



20
21
22
# File 'lib/ellen/message.rb', line 20

def robot
  @original[:robot]
end

#toObject



24
25
26
# File 'lib/ellen/message.rb', line 24

def to
  @original[:to]
end