Class: Noaidi::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/noaidi/matcher.rb

Instance Method Summary collapse

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

Returns:

  • (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_classObject



18
19
20
# File 'lib/noaidi/matcher.rb', line 18

def pattern_class
  @pattern.class
end