Class: CrossLanguageSpotter::CrossLanguageRelation

Inherits:
Object
  • Object
show all
Defined in:
lib/crosslanguagespotter/figures_evaluator.rb

Overview

It is a set of two node_ids (unordered)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_ids) ⇒ CrossLanguageRelation

Returns a new instance of CrossLanguageRelation.



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 86

def initialize(node_ids)
    raise "Two elements expected, #{node_ids.count} found" unless node_ids.count==2
    node_id_a = node_ids[0]
    node_id_b = node_ids[1]
    if (node_id_a<=>node_id_b)<0
        @node_ids = [node_id_a,node_id_b]
    else
        @node_ids = [node_id_b,node_id_a]
    end     
    #puts "SORTING GAVE #{@node_ids}"
end

Instance Attribute Details

#node_idsObject (readonly)

Returns the value of attribute node_ids.



84
85
86
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 84

def node_ids
  @node_ids
end

Instance Method Details

#==(other) ⇒ Object



103
104
105
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 103

def ==(other)
    return self.eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


98
99
100
101
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 98

def eql?(other)
    return false unless other.is_a?(CrossLanguageRelation)
    self.node_ids.eql?(other.node_ids)
end

#hashObject



107
108
109
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 107

def hash
    @node_ids[0].hash*7+@node_ids[1].hash
end

#to_sObject



111
112
113
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 111

def to_s
    "CrossLanguageRelation #{@node_ids[0]} <-> #{@node_ids[1]}"
end