Class: Topiary::Graph
- Inherits:
-
Object
- Object
- Topiary::Graph
- Defined in:
- lib/topiary/graph.rb
Overview
Represents a Graph
Direct Known Subclasses
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
-
#initialize(nodes = []) ⇒ Graph
constructor
A new instance of Graph.
- #to_s ⇒ Object
Constructor Details
#initialize(nodes = []) ⇒ Graph
Returns a new instance of Graph.
6 7 8 |
# File 'lib/topiary/graph.rb', line 6 def initialize(nodes=[]) @nodes = nodes end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
4 5 6 |
# File 'lib/topiary/graph.rb', line 4 def nodes @nodes end |
Instance Method Details
#to_s ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/topiary/graph.rb', line 10 def to_s ar = nodes.map(&:to_s) if ar.empty? "{ }" else "{ #{ar.join('; ')} }" end end |