Class: EideticRML::Styles::StyleCollection
- Inherits:
-
Array
- Object
- Array
- EideticRML::Styles::StyleCollection
- Defined in:
- lib/erml_styles.rb
Instance Method Summary collapse
Instance Method Details
#add(name, attrs = {}) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/erml_styles.rb', line 69 def add(name, attrs={}) raise ArgumentError, "id required for style" if attrs[:id].nil? style = for_id(attrs[:id]) if style.nil? if (style_class = Style.for_name(name.to_s)).nil? raise ArgumentError, "Unknown style #{name}." end style = style_class.new(self, attrs) self << style else attrs.each { |key, value| style.send(key, value) } end style end |
#for_id(id) ⇒ Object
84 85 86 |
# File 'lib/erml_styles.rb', line 84 def for_id(id) find { |style| style.id == id } end |