Class: TelegramBot::CommandMatcher
- Defined in:
- lib/telegram_bot/matcher.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
Instance Method Summary collapse
- #===(msg) ⇒ Object
- #arguments(msg) ⇒ Object
-
#initialize(command) ⇒ CommandMatcher
constructor
A new instance of CommandMatcher.
Constructor Details
#initialize(command) ⇒ CommandMatcher
Returns a new instance of CommandMatcher.
38 39 40 |
# File 'lib/telegram_bot/matcher.rb', line 38 def initialize(command) @command = command end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
36 37 38 |
# File 'lib/telegram_bot/matcher.rb', line 36 def command @command end |
Instance Method Details
#===(msg) ⇒ Object
42 43 44 |
# File 'lib/telegram_bot/matcher.rb', line 42 def ===(msg) msg.type == :text and msg.text.start_with?("/#{@command}") end |
#arguments(msg) ⇒ Object
46 47 48 |
# File 'lib/telegram_bot/matcher.rb', line 46 def arguments(msg) msg.text.split[1..-1] end |