Class: BotMob::InboundMessage
- Inherits:
-
Object
- Object
- BotMob::InboundMessage
- Defined in:
- lib/bot_mob/inbound_message.rb
Overview
## BotMob::InboundMessage
The InboundMessage class provides easy access to messages received by bots in your application
Direct Known Subclasses
Instance Attribute Summary collapse
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #arguments ⇒ Object
-
#initialize(text) ⇒ InboundMessage
constructor
A new instance of InboundMessage.
Constructor Details
#initialize(text) ⇒ InboundMessage
Returns a new instance of InboundMessage.
9 10 11 |
# File 'lib/bot_mob/inbound_message.rb', line 9 def initialize(text) @text = text end |
Instance Attribute Details
#network ⇒ Object (readonly)
Returns the value of attribute network.
7 8 9 |
# File 'lib/bot_mob/inbound_message.rb', line 7 def network @network end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/bot_mob/inbound_message.rb', line 7 def params @params end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/bot_mob/inbound_message.rb', line 7 def text @text end |
Class Method Details
.parse(params) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/bot_mob/inbound_message.rb', line 13 def self.parse(params) network = params[:network] invalid_network_error(network) unless BotMob.valid_network?(network) parser = network_delegate(network) invalid_delegate_error(network) unless parser.respond_to?(:parse) parser.parse(params) end |
Instance Method Details
#arguments ⇒ Object
23 24 25 |
# File 'lib/bot_mob/inbound_message.rb', line 23 def arguments @arguments ||= text.to_s[%r{\/[\w'_-]+\s*[\w'_-]+\s*(.*)}, 1] end |