Class: Seafoam::Edge

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

Overview

A directed edge, with a node it’s from and a node it’s going to, and properties.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to, props = nil) ⇒ Edge

Returns a new instance of Edge.



83
84
85
86
87
88
# File 'lib/seafoam/graph.rb', line 83

def initialize(from, to, props = nil)
  props ||= {}
  @from = from
  @to = to
  @props = props
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



81
82
83
# File 'lib/seafoam/graph.rb', line 81

def from
  @from
end

#propsObject (readonly)

Returns the value of attribute props.



81
82
83
# File 'lib/seafoam/graph.rb', line 81

def props
  @props
end

#toObject (readonly)

Returns the value of attribute to.



81
82
83
# File 'lib/seafoam/graph.rb', line 81

def to
  @to
end

Instance Method Details

#inspectObject

Inspect.



96
97
98
# File 'lib/seafoam/graph.rb', line 96

def inspect
  "<Edge #{from.id} -> #{to.id}>"
end

#nodesObject

Both nodes - from and to.



91
92
93
# File 'lib/seafoam/graph.rb', line 91

def nodes
  [@from, @to]
end