Class: Mementus::Edge

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from = nil, to = nil, label = :edge) ⇒ Edge

Returns a new instance of Edge.



5
6
7
8
9
# File 'lib/mementus/edge.rb', line 5

def initialize(from=nil, to=nil, label=:edge)
  @from = from
  @to = to
  @label = label
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



3
4
5
# File 'lib/mementus/edge.rb', line 3

def from
  @from
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/mementus/edge.rb', line 3

def label
  @label
end

#toObject

Returns the value of attribute to.



3
4
5
# File 'lib/mementus/edge.rb', line 3

def to
  @to
end

Instance Method Details

#nodesObject



31
32
33
# File 'lib/mementus/edge.rb', line 31

def nodes
  [@from, @to]
end

#other(node) ⇒ Object



35
36
37
# File 'lib/mementus/edge.rb', line 35

def other(node)
  @from == node ? @to : @from
end