Class: Graph::Attribute
Overview
An attribute for a graph, node, or edge. Really just a composable string (via #+) with a convenience method #<< that allows you to “paint” nodes and edges with this attribute.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attr ⇒ Object
(also: #to_s)
Returns the value of attribute attr.
Instance Method Summary collapse
-
#+(style) ⇒ Object
Compose a new attribute from two existing attributes:.
-
#<<(thing) ⇒ Object
“Paint” graphs, nodes, and edges with this attribute.
Instance Attribute Details
#attr ⇒ Object Also known as: to_s
Returns the value of attribute attr
462 463 464 |
# File 'lib/graph.rb', line 462 def attr @attr end |
Instance Method Details
#+(style) ⇒ Object
Compose a new attribute from two existing attributes:
bad_nodes = red + filled + diamond
489 490 491 492 493 494 |
# File 'lib/graph.rb', line 489 def + style c = CompoundAttribute.new c.push self c.push style c end |
#<<(thing) ⇒ Object
“Paint” graphs, nodes, and edges with this attribute.
red << node1 << node2 << node3
is the same as:
node1.attributes << red
node2.attributes << red
node3.attributes << red
474 475 476 477 |
# File 'lib/graph.rb', line 474 def << thing thing.attributes << self self end |