Class: CrossLanguageSpotter::NodeId

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, node_index) ⇒ NodeId

Returns a new instance of NodeId.



49
50
51
52
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 49

def initialize(file,node_index)
    @file = file
    @node_index = node_index
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



38
39
40
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 38

def file
  @file
end

#node_indexObject (readonly)

Returns the value of attribute node_index.



39
40
41
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 39

def node_index
  @node_index
end

Class Method Details

.from_node(node) ⇒ Object



45
46
47
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 45

def self.from_node(node)
    new(node.source.artifact.final_host.filename,traverse_index(node))
end

Instance Method Details

#<=>(other) ⇒ Object



67
68
69
70
71
72
73
74
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 67

def <=>(other)
    res = self.file <=> other.file
    if res==0
        self.node_index <=> other.node_index
    else
        res
    end
end

#==(other) ⇒ Object



59
60
61
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 59

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 54

def eql?(other)
    return false unless other.is_a?(NodeId)
    self.file.eql?(other.file) && self.node_index.eql?(other.node_index)
end

#hashObject



63
64
65
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 63

def hash
    @file.hash*7+@node_index.hash
end

#indexObject



41
42
43
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 41

def index
    @node_index
end

#to_sObject



76
77
78
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 76

def to_s
    "#{@file}:#{@node_index}"
end