Class: Graph::CompoundAttribute

Inherits:
Attribute show all
Defined in:
lib/graph.rb

Overview

An attribute… that’s compound. So much for self-documenting code. :(

Instance Attribute Summary

Attributes inherited from Attribute

#attr

Instance Method Summary collapse

Methods inherited from Attribute

#+

Constructor Details

#initialize(attr = []) ⇒ CompoundAttribute

:nodoc:



485
486
487
# File 'lib/graph.rb', line 485

def initialize attr = [] # :nodoc:
  super
end

Instance Method Details

#<<(thing) ⇒ Object

“Paint” a thingy with an attribute. Applies the attribute to the thingy. In this case, does it recursively.



500
501
502
503
504
505
# File 'lib/graph.rb', line 500

def << thing
  attr.each do |subattr|
    subattr << thing # allows for recursive compound attributes
  end
  self
end

#push(attrib) ⇒ Object

Push an attribute into the list o’ attributes.



492
493
494
# File 'lib/graph.rb', line 492

def push attrib
  attr.push attrib
end

#to_sObject

:nodoc:



507
508
509
# File 'lib/graph.rb', line 507

def to_s # :nodoc:
  attr.join ", "
end