Class: Lorax::Match

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @pair    = [node1, node2]
  @perfect = options[:perfect] ? true : false
end

Instance Attribute Details

#pairObject

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

Returns:

  • (Boolean)


10
11
12
# File 'lib/lorax/match.rb', line 10

def perfect?
  @perfect
end