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.
31 32 33 |
# File 'lib/ctioga2/graphics/legends/storage.rb', line 31 def initialize @contents = [] end |
Instance Attribute Details
#contents ⇒ Object
An array of LegendItem objects, in the order in which they should get displayed.
29 30 31 |
# File 'lib/ctioga2/graphics/legends/storage.rb', line 29 def contents @contents end |
Instance Method Details
#add_item(item) ⇒ Object
Adds a LegendItem or a Container to the LegendStorage object.
37 38 39 |
# File 'lib/ctioga2/graphics/legends/storage.rb', line 37 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.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ctioga2/graphics/legends/storage.rb', line 44 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 |