Class: Lita::Response
- Inherits:
-
Object
- Object
- Lita::Response
- Extended by:
- Forwardable
- Defined in:
- lib/lita/response.rb
Overview
A wrapper object that provides the primary interface for handlers to respond to incoming chat messages.
Instance Attribute Summary collapse
-
#extensions ⇒ Hash
A hash of arbitrary data that can be populated by Lita extensions.
-
#message ⇒ Lita::Message
The incoming message.
-
#pattern ⇒ Regexp
The pattern the incoming message matched.
Instance Method Summary collapse
- #args ⇒ Object
-
#initialize(message, pattern) ⇒ Response
constructor
A new instance of Response.
-
#match_data ⇒ MatchData
A
MatchData
object from running the pattern against the message body. -
#matches ⇒ Array<String>+
An array of matches from scanning the message against the route pattern.
- #reply ⇒ Object
- #reply_privately ⇒ Object
- #reply_with_mention ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(message, pattern) ⇒ Response
Returns a new instance of Response
35 36 37 38 39 |
# File 'lib/lita/response.rb', line 35 def initialize(, pattern) self. = self.extensions = {} self.pattern = pattern end |
Instance Attribute Details
#extensions ⇒ Hash
A hash of arbitrary data that can be populated by Lita extensions.
14 15 16 |
# File 'lib/lita/response.rb', line 14 def extensions @extensions end |
#message ⇒ Lita::Message
The incoming message.
9 10 11 |
# File 'lib/lita/response.rb', line 9 def @message end |
#pattern ⇒ Regexp
The pattern the incoming message matched.
18 19 20 |
# File 'lib/lita/response.rb', line 18 def pattern @pattern end |
Instance Method Details
#args ⇒ Object
30 31 |
# File 'lib/lita/response.rb', line 30 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :command? |
#match_data ⇒ MatchData
A MatchData
object from running the pattern against the
message body.
49 50 51 |
# File 'lib/lita/response.rb', line 49 def match_data @match_data ||= pattern.match(.body) end |
#matches ⇒ Array<String>+
An array of matches from scanning the message against the route pattern.
43 44 45 |
# File 'lib/lita/response.rb', line 43 def matches @matches ||= .match(pattern) end |
#reply ⇒ Object
30 31 |
# File 'lib/lita/response.rb', line 30 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :command? |
#reply_privately ⇒ Object
30 31 |
# File 'lib/lita/response.rb', line 30 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :command? |
#reply_with_mention ⇒ Object
30 31 |
# File 'lib/lita/response.rb', line 30 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :command? |
#user ⇒ Object
30 31 |
# File 'lib/lita/response.rb', line 30 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :command? |