Class: Vanguard::Matcher::Nullary::Proc

Inherits:
Vanguard::Matcher::Nullary show all
Defined in:
lib/vanguard/matcher/nullary/proc.rb

Overview

A matcher that delegates to block

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize object

Parameters:



37
38
39
# File 'lib/vanguard/matcher/nullary/proc.rb', line 37

def initialize(block)
  @block = block
end

Instance Attribute Details

#blockProc (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return block

Returns:



15
16
17
# File 'lib/vanguard/matcher/nullary/proc.rb', line 15

def block
  @block
end

Instance Method Details

#matches?(input) ⇒ true, false

Test if value matches

Returns:

  • (true)

    if block returns non falsy value

  • (false)

    otherwise



25
26
27
# File 'lib/vanguard/matcher/nullary/proc.rb', line 25

def matches?(input)
  !!@block.call(input)
end