Class: JavaClass::Dependencies::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/javaclass/dependencies/edge.rb

Overview

An edge in the Graph of dependencies. An edge knows it’s source and destination details.

Author

Peter Kofler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, target) ⇒ Edge

Returns a new instance of Edge.



11
12
13
14
# File 'lib/javaclass/dependencies/edge.rb', line 11

def initialize(source, target)
  @source = source
  @target = target
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



8
9
10
# File 'lib/javaclass/dependencies/edge.rb', line 8

def source
  @source
end

#targetObject (readonly)

Returns the value of attribute target.



9
10
11
# File 'lib/javaclass/dependencies/edge.rb', line 9

def target
  @target
end

Instance Method Details

#<=>(other) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/javaclass/dependencies/edge.rb', line 30

def <=>(other)
  res = @target <=> other.target
  if res == 0
    res = @source <=> other.source
  end
  res 
end

#==(other) ⇒ Object Also known as: eql?



20
21
22
# File 'lib/javaclass/dependencies/edge.rb', line 20

def ==(other)
  @source == other.source && @target == other.target 
end

#hashObject



26
27
28
# File 'lib/javaclass/dependencies/edge.rb', line 26

def hash
  [@source, @target].hash
end

#to_sObject



16
17
18
# File 'lib/javaclass/dependencies/edge.rb', line 16

def to_s
  "#{@target} (#{@source})"
end