Module: CqlRuby::PatternMatcher

Defined in:
lib/cql_ruby/pattern_matcher.rb

Constant Summary collapse

MATCH_ANY =
'*'

Class Method Summary collapse

Class Method Details

.match?(pattern, subject) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cql_ruby/pattern_matcher.rb', line 6

def self.match?(pattern, subject)
  pattern = pattern.to_s
  return true if pattern == MATCH_ANY

  subject = subject.to_s

  if regex?(pattern)
    regex_match?(pattern, subject)
  elsif partial_string?(pattern)
    partial_string_match?(pattern, subject)
  else
    full_string_match?(pattern, subject)
  end
end