Class: Noaidi::Matcher
- Inherits:
-
Object
- Object
- Noaidi::Matcher
- Defined in:
- lib/noaidi/matcher.rb
Instance Method Summary collapse
-
#initialize(pattern) ⇒ Matcher
constructor
A new instance of Matcher.
- #match?(value) ⇒ Boolean
- #pattern_class ⇒ Object
Constructor Details
#initialize(pattern) ⇒ Matcher
Returns a new instance of Matcher.
3 4 5 |
# File 'lib/noaidi/matcher.rb', line 3 def initialize(pattern) @pattern = pattern end |
Instance Method Details
#match?(value) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/noaidi/matcher.rb', line 7 def match?(value) case @pattern when Proc match_with_lambda(value) when Hash match_with_hash(value) else @pattern === value end end |
#pattern_class ⇒ Object
18 19 20 |
# File 'lib/noaidi/matcher.rb', line 18 def pattern_class @pattern.class end |