Class: CTioga2::Graphics::Legends::LegendStorage
- Inherits:
-
Object
- Object
- CTioga2::Graphics::Legends::LegendStorage
- Defined in:
- lib/ctioga2/graphics/legends/storage.rb
Overview
This class holds a series of legends for curves.
Instance Attribute Summary collapse
-
#contents ⇒ Object
An array of LegendItem objects, in the order in which they should get displayed.
Instance Method Summary collapse
-
#add_item(item) ⇒ Object
Adds a LegendItem or a Container to the LegendStorage object.
-
#harvest_contents ⇒ Object
Returns a flat array of LegendItem that belong to the same LegendArea as the object in which the LegendStorage was created.
-
#initialize ⇒ LegendStorage
constructor
A new instance of LegendStorage.
Constructor Details
#initialize ⇒ LegendStorage
Returns a new instance of LegendStorage.
33 34 35 |
# File 'lib/ctioga2/graphics/legends/storage.rb', line 33 def initialize @contents = [] end |
Instance Attribute Details
#contents ⇒ Object
An array of LegendItem objects, in the order in which they should get displayed.
31 32 33 |
# File 'lib/ctioga2/graphics/legends/storage.rb', line 31 def contents @contents end |
Instance Method Details
#add_item(item) ⇒ Object
Adds a LegendItem or a Container to the LegendStorage object.
39 40 41 |
# File 'lib/ctioga2/graphics/legends/storage.rb', line 39 def add_item(item) @contents << item end |
#harvest_contents ⇒ Object
Returns a flat array of LegendItem that belong to the same LegendArea as the object in which the LegendStorage was created.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ctioga2/graphics/legends/storage.rb', line 46 def harvest_contents retval = [] for el in @contents if el.is_a? LegendItem retval << el elsif el.is_a? Elements::Container and (not el.legend_area) if el.legend_storage retval.concat(el.legend_storage.harvest_contents) end end end return retval end |