Class: Waylon::Conditions::Regex
- Inherits:
-
Waylon::Condition
- Object
- Waylon::Condition
- Waylon::Conditions::Regex
- Defined in:
- lib/waylon/conditions/regex.rb
Overview
Routing via Regular Expression
Instance Attribute Summary
Attributes inherited from Waylon::Condition
Instance Method Summary collapse
-
#matches?(message) ⇒ Boolean
Checks if this condition matches the message.
-
#named_tokens(input) ⇒ Hash<Symbol,String>
Provides the named regular expression match groups as a hash.
-
#tokens(input) ⇒ Array<String>
Provides the regular expression match groups as tokens.
Methods inherited from Waylon::Condition
#initialize, #mention_only?, #permits?, #properly_mentions?
Constructor Details
This class inherits a constructor from Waylon::Condition
Instance Method Details
#matches?(message) ⇒ Boolean
Checks if this condition matches the message
10 11 12 |
# File 'lib/waylon/conditions/regex.rb', line 10 def matches?() @mechanism =~ end |
#named_tokens(input) ⇒ Hash<Symbol,String>
Provides the named regular expression match groups as a hash
24 25 26 27 |
# File 'lib/waylon/conditions/regex.rb', line 24 def named_tokens(input) match_data = @mechanism.match(input) match_data.names.to_h { |n| [n.to_sym, match_data[n]] } end |
#tokens(input) ⇒ Array<String>
Provides the regular expression match groups as tokens
17 18 19 |
# File 'lib/waylon/conditions/regex.rb', line 17 def tokens(input) @mechanism.match(input).to_a[1..] end |