Class: Either::Match
- Inherits:
-
Object
- Object
- Either::Match
- Defined in:
- lib/either/match.rb
Defined Under Namespace
Classes: Evaluation
Instance Attribute Summary collapse
-
#lefts ⇒ Object
readonly
Returns the value of attribute lefts.
-
#rights ⇒ Object
readonly
Returns the value of attribute rights.
Instance Method Summary collapse
- #evaluate(either) ⇒ Object
-
#initialize ⇒ Match
constructor
A new instance of Match.
- #left(pattern = always, &block) ⇒ Object
- #right(pattern = always, &block) ⇒ Object
Constructor Details
#initialize ⇒ Match
Returns a new instance of Match.
4 5 6 7 |
# File 'lib/either/match.rb', line 4 def initialize @lefts = [] @rights = [] end |
Instance Attribute Details
#lefts ⇒ Object (readonly)
Returns the value of attribute lefts.
21 22 23 |
# File 'lib/either/match.rb', line 21 def lefts @lefts end |
#rights ⇒ Object (readonly)
Returns the value of attribute rights.
21 22 23 |
# File 'lib/either/match.rb', line 21 def rights @rights end |
Instance Method Details
#evaluate(either) ⇒ Object
17 18 19 |
# File 'lib/either/match.rb', line 17 def evaluate(either) Evaluation.new(self, either).result end |
#left(pattern = always, &block) ⇒ Object
9 10 11 |
# File 'lib/either/match.rb', line 9 def left pattern=always, &block @lefts << [(lambify pattern), block] end |
#right(pattern = always, &block) ⇒ Object
13 14 15 |
# File 'lib/either/match.rb', line 13 def right pattern=always, &block @rights << [(lambify pattern), block] end |