Class: Option::Match::SomeClause

Inherits:
Object
  • Object
show all
Defined in:
lib/optional/option/match.rb

Instance Method Summary collapse

Constructor Details

#initialize(guard = always, block = lambda{}) ⇒ SomeClause

Returns a new instance of SomeClause.



45
46
47
48
# File 'lib/optional/option/match.rb', line 45

def initialize(guard=always, block=lambda{})
  @guard = guard
  @block = block
end

Instance Method Details

#evaluate(value) ⇒ Object



54
55
56
# File 'lib/optional/option/match.rb', line 54

def evaluate(value)
  block.call(value)
end

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/optional/option/match.rb', line 50

def matches?(value)
  guard.call(value)
end