Class: Diligence::Route
- Inherits:
-
Object
- Object
- Diligence::Route
- Defined in:
- lib/diligence/route.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#matcher ⇒ Object
readonly
Returns the value of attribute matcher.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, matcher:, handler:) ⇒ Route
constructor
A new instance of Route.
- #match(message_update) ⇒ Object
Constructor Details
#initialize(type:, matcher:, handler:) ⇒ Route
Returns a new instance of Route.
7 8 9 10 11 |
# File 'lib/diligence/route.rb', line 7 def initialize(type:, matcher:, handler:) @type = type @matcher = matcher @handler = handler end |
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
5 6 7 |
# File 'lib/diligence/route.rb', line 5 def handler @handler end |
#matcher ⇒ Object (readonly)
Returns the value of attribute matcher.
5 6 7 |
# File 'lib/diligence/route.rb', line 5 def matcher @matcher end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/diligence/route.rb', line 5 def type @type end |
Instance Method Details
#match(message_update) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/diligence/route.rb', line 13 def match() result = ( case @type when :chat_id match_chat_id?() when :user_id match_user_id?() when :chat_type match_chat_type?() when :message_type () when :text_pattern match_text_pattern?() when :default true else false end ) result ? @handler : nil end |