Class: Lorax::Match
- Inherits:
-
Object
- Object
- Lorax::Match
- Defined in:
- lib/lorax/match.rb
Instance Attribute Summary collapse
-
#pair ⇒ Object
Returns the value of attribute pair.
Instance Method Summary collapse
-
#initialize(node1, node2, options = {}) ⇒ Match
constructor
A new instance of Match.
- #other(node) ⇒ Object
- #perfect? ⇒ Boolean
Constructor Details
#initialize(node1, node2, options = {}) ⇒ Match
Returns a new instance of Match.
5 6 7 8 |
# File 'lib/lorax/match.rb', line 5 def initialize(node1, node2, ={}) @pair = [node1, node2] @perfect = [:perfect] ? true : false end |
Instance Attribute Details
#pair ⇒ Object
Returns the value of attribute pair.
3 4 5 |
# File 'lib/lorax/match.rb', line 3 def pair @pair end |
Instance Method Details
#other(node) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/lorax/match.rb', line 14 def other(node) case node when pair.first then pair.last when pair.last then pair.first else nil end end |
#perfect? ⇒ Boolean
10 11 12 |
# File 'lib/lorax/match.rb', line 10 def perfect? @perfect end |