Class: GraphAgent::Graph::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/graph_agent/graph/edge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, target) ⇒ Edge

Returns a new instance of Edge.



8
9
10
11
# File 'lib/graph_agent/graph/edge.rb', line 8

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

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/graph_agent/graph/edge.rb', line 6

def source
  @source
end

#targetObject (readonly)

Returns the value of attribute target.



6
7
8
# File 'lib/graph_agent/graph/edge.rb', line 6

def target
  @target
end

Instance Method Details

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



13
14
15
# File 'lib/graph_agent/graph/edge.rb', line 13

def ==(other)
  other.is_a?(Edge) && source == other.source && target == other.target
end

#hashObject



18
19
20
# File 'lib/graph_agent/graph/edge.rb', line 18

def hash
  [source, target].hash
end