class Osheet::WorkbookElement::TemplateSet
Public Class Methods
new()
click to toggle source
this class is a PartialSet that keys off of the template element and name. Only Osheet::Template
objs can be pushed, and you reference a particular template by its element and name
Calls superclass method
Osheet::WorkbookElement::PartialSet::new
# File lib/osheet/workbook_element.rb, line 122 def initialize super end
Public Instance Methods
get(element, name)
click to toggle source
return the template set for the named element
# File lib/osheet/workbook_element.rb, line 127 def get(element, name) lookup(key(element.to_s, name.to_s)) end
Private Instance Methods
key(element, name)
click to toggle source
# File lib/osheet/workbook_element.rb, line 158 def key(element, name) [element.to_s, name.to_s] end
lookup(key)
click to toggle source
# File lib/osheet/workbook_element.rb, line 133 def lookup(key) self[key.first][key.last] if self[key.first] end
push(key, template)
click to toggle source
push the template onto the key
# File lib/osheet/workbook_element.rb, line 138 def push(key, template) self[key.first][key.last] = template end
template_key(template)
click to toggle source
# File lib/osheet/workbook_element.rb, line 154 def template_key(template) key(template.instance_variable_get("@element"), template.instance_variable_get("@name")) end
verify(template)
click to toggle source
verify the template, init the key set, and return the key string
otherwise ArgumentError it up
# File lib/osheet/workbook_element.rb, line 144 def verify(template) unless template.kind_of?(Template) raise ArgumentError, 'you can only push Osheet::Template objs to the template set' end key = template_key(template) self[key.first] ||= {} self[key.first][key.last] ||= nil key end