Class: Qo::Matchers::Matcher
- Inherits:
-
Object
- Object
- Qo::Matchers::Matcher
- Defined in:
- lib/qo/matchers/matcher.rb
Overview
Matcher used to determine whether a value matches a certain set of conditions
Instance Method Summary collapse
-
#call(target) ⇒ Boolean
(also: #===, #[], #match?)
Calls the matcher on a given target value.
-
#initialize(type, array_matchers = [], keyword_matchers = {}) ⇒ Qo::Matchers::Matcher
constructor
Creates a new matcher.
-
#to_proc ⇒ Proc[Any] => Boolean
Proc-ified version of
call
.
Constructor Details
#initialize(type, array_matchers = [], keyword_matchers = {}) ⇒ Qo::Matchers::Matcher
Creates a new matcher
23 24 25 26 27 |
# File 'lib/qo/matchers/matcher.rb', line 23 def initialize(type, array_matchers = [], keyword_matchers = {}) @type = type @array_matchers = array_matchers @keyword_matchers = keyword_matchers end |
Instance Method Details
#call(target) ⇒ Boolean Also known as: ===, [], match?
Calls the matcher on a given target value
43 44 45 |
# File 'lib/qo/matchers/matcher.rb', line 43 def call(target) combined_check(array_call(target), keyword_call(target)) end |
#to_proc ⇒ Proc[Any] => Boolean
Proc-ified version of call
32 33 34 |
# File 'lib/qo/matchers/matcher.rb', line 32 def to_proc -> target { self.call(target) } end |