Class: CrossLanguageSpotter::Pair
- Inherits:
-
Object
- Object
- CrossLanguageSpotter::Pair
- Defined in:
- lib/crosslanguagespotter/methods/context.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #first ⇒ Object
- #hash ⇒ Object
-
#initialize(a, b) ⇒ Pair
constructor
A new instance of Pair.
- #nodes ⇒ Object
- #second ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(a, b) ⇒ Pair
Returns a new instance of Pair.
8 9 10 11 12 13 14 15 16 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 8 def initialize(a,b) raise "error" unless a.source.position(:absolute) raise "error" unless b.source.position(:absolute) if b.source.artifact(:absolute).filename < a.source.artifact(:absolute).filename @nodes = [b,a] else @nodes = [a,b] end end |
Instance Method Details
#==(other) ⇒ Object
35 36 37 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 35 def ==(other) self.eql?(other) end |
#eql?(other) ⇒ Boolean
30 31 32 33 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 30 def eql?(other) return false unless other.is_a?(Pair) self.nodes[0]==other.nodes[0] && self.nodes[1]==other.nodes[1] end |
#first ⇒ Object
18 19 20 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 18 def first nodes[0] end |
#hash ⇒ Object
43 44 45 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 43 def hash nodes[0].hash*3+nodes[1].hash end |
#nodes ⇒ Object
26 27 28 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 26 def nodes @nodes end |
#second ⇒ Object
22 23 24 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 22 def second nodes[1] end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 39 def to_s "[#{nodes[0]} <-> #{nodes[1]}]" end |