Class: Osheet::Template

Inherits:
Partial
  • Object
show all
Includes:
Instance
Defined in:
lib/osheet/template.rb

Constant Summary collapse

ELEMENTS =
['worksheet', 'column', 'row', 'cell']

Instance Method Summary collapse

Methods inherited from Partial

#name, #name=

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

  set_ivar(:element, element.to_s)
  super(name)
end

Instance Method Details

#elementObject



23
# File 'lib/osheet/template.rb', line 23

def element; get_ivar(:element); end

#element=(v) ⇒ Object



24
# File 'lib/osheet/template.rb', line 24

def element=(v); set_ivar(:element, v); end