Class: Abuelo::Node
- Inherits:
-
Object
- Object
- Abuelo::Node
- Defined in:
- lib/abuelo/node.rb
Overview
Class Node provides a representation of a node. A node has a name. Any object may be attached on initialization.
Instance Attribute Summary collapse
-
#graph ⇒ Abuelo::Graph
Associated graph.
-
#name ⇒ String
readonly
Name.
-
#object ⇒ Object
readonly
Attached object.
Instance Method Summary collapse
-
#==(other_node) ⇒ Boolean
Equality check.
-
#edges ⇒ Array<Abuelo::Edge>
List of edges starting from the node.
-
#initialize(name, object = nil) ⇒ Node
constructor
Initialiazises the node with its name.
-
#to_s ⇒ String
Human readable representation of node.
Constructor Details
#initialize(name, object = nil) ⇒ Node
Initialiazises the node with its name.
25 26 27 28 |
# File 'lib/abuelo/node.rb', line 25 def initialize(name, object = nil) @name = name @object = object end |
Instance Attribute Details
#graph ⇒ Abuelo::Graph
Returns associated graph.
16 17 18 |
# File 'lib/abuelo/node.rb', line 16 def graph @graph end |
#name ⇒ String (readonly)
Returns name.
10 11 12 |
# File 'lib/abuelo/node.rb', line 10 def name @name end |
#object ⇒ Object (readonly)
Returns attached object.
13 14 15 |
# File 'lib/abuelo/node.rb', line 13 def object @object end |
Instance Method Details
#==(other_node) ⇒ Boolean
Equality check.
51 52 53 |
# File 'lib/abuelo/node.rb', line 51 def ==(other_node) self.name == other_node.name end |
#edges ⇒ Array<Abuelo::Edge>
Returns list of edges starting from the node.
33 34 35 |
# File 'lib/abuelo/node.rb', line 33 def edges graph.edges_for_node(self) if graph end |
#to_s ⇒ String
Returns human readable representation of node.
40 41 42 |
# File 'lib/abuelo/node.rb', line 40 def to_s @name end |