Class: Osheet::Template
Constant Summary collapse
- ELEMENTS =
this class is a partial that is associated with an osheet element if an element is initialized from a template, the template block will be instance_eval’d for the element being initialized
['worksheet', 'column', 'row', 'cell']
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
Attributes inherited from Partial
Instance Method Summary collapse
-
#initialize(element, name) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(element, name) ⇒ Template
Returns a new instance of Template.
14 15 16 17 18 19 20 21 |
# File 'lib/osheet/template.rb', line 14 def initialize(element, name) unless element.respond_to?(:to_s) && ELEMENTS.include?(element.to_s) raise ArgumentError, "you can only define a template for #{ELEMENTS.join(', ')} elements." end @element = element.to_s super(name) end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
12 13 14 |
# File 'lib/osheet/template.rb', line 12 def element @element end |