lib/ellen/message.rb in ellen-0.2.1 vs lib/ellen/message.rb in ellen-0.2.2
- old
+ new
@@ -1,31 +1,41 @@
module Ellen
class Message
attr_reader(
- :body,
- :from,
:match_data,
- :robot,
- :to,
+ :original,
)
- def initialize(options)
- @body = options[:body]
- @from = options[:from]
- @robot = options[:robot]
- @to = options[:to]
+ def initialize(original)
+ @original = original
end
+ def body
+ @original[:body]
+ end
+
+ def from
+ @original[:from]
+ end
+
+ def robot
+ @original[:robot]
+ end
+
+ def to
+ @original[:to]
+ end
+
def match(pattern)
@match_data = pattern.match(body)
end
def [](index)
match_data[index]
end
def reply(body, options = {})
- attributes = { body: body, from: from, to: to }.merge(options)
+ attributes = { body: body, from: to, to: from, original: original }.merge(options)
robot.say(attributes)
end
end
end