Class: Graph::Thingy
- Inherits:
-
Struct
- Object
- Struct
- Graph::Thingy
- Defined in:
- lib/graph.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#graph ⇒ Object
Returns the value of attribute graph.
Instance Method Summary collapse
-
#attributes? ⇒ Boolean
Does this thing have attributes?.
-
#initialize(graph) ⇒ Thingy
constructor
A new instance of Thingy.
-
#initialize_copy(other) ⇒ Object
:nodoc:.
-
#label(name) ⇒ Object
Shortcut method to set the label attribute.
Constructor Details
#initialize(graph) ⇒ Thingy
Returns a new instance of Thingy.
433 434 435 |
# File 'lib/graph.rb', line 433 def initialize graph super graph, [] end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes
432 433 434 |
# File 'lib/graph.rb', line 432 def attributes @attributes end |
#graph ⇒ Object
Returns the value of attribute graph
432 433 434 |
# File 'lib/graph.rb', line 432 def graph @graph end |
Instance Method Details
#attributes? ⇒ Boolean
Does this thing have attributes?
454 455 456 |
# File 'lib/graph.rb', line 454 def attributes? not self.attributes.empty? end |
#initialize_copy(other) ⇒ Object
:nodoc:
437 438 439 440 |
# File 'lib/graph.rb', line 437 def initialize_copy other # :nodoc: super self.attributes = other.attributes.dup end |
#label(name) ⇒ Object
Shortcut method to set the label attribute.
445 446 447 448 449 |
# File 'lib/graph.rb', line 445 def label name attributes.reject! { |s| s =~ /^label =/ } attributes << "label = \"#{name.gsub(/\n/, '\n')}\"" self end |