Class: Qo::GuardBlockMatcher
- Defined in:
- lib/qo/guard_block_matcher.rb
Constant Summary collapse
- IDENTITY =
-> v { v }
Instance Method Summary collapse
-
#initialize(*array_matchers, **keyword_matchers, &fn) ⇒ GuardBlockMatcher
constructor
A new instance of GuardBlockMatcher.
- #to_proc ⇒ Object
Methods inherited from Matcher
Constructor Details
#initialize(*array_matchers, **keyword_matchers, &fn) ⇒ GuardBlockMatcher
Returns a new instance of GuardBlockMatcher.
5 6 7 8 9 |
# File 'lib/qo/guard_block_matcher.rb', line 5 def initialize(*array_matchers, **keyword_matchers, &fn) @fn = fn || IDENTITY super('and', *array_matchers, **keyword_matchers) end |
Instance Method Details
#to_proc ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/qo/guard_block_matcher.rb', line 11 def to_proc Proc.new { |match_target| next [false, false] unless super[match_target] [true, @fn.call(match_target)] } end |