class Osheet::WorkbookElement::PartialSet
This ‘WorkbookElement’ class handles all workbook state. It is setup and referenced by the ‘Workbook’ class when it runs builds
Public Class Methods
new()
click to toggle source
this class is a Hash that behaves kinda like a set. I want to push partials into the set using the ‘<<’ operator, only allow Osheet::Partial
objs to be pushed, and then be able to reference a particular partial using its name
Calls superclass method
# File lib/osheet/workbook_element.rb, line 69 def initialize super end
Public Instance Methods
<<(partial)
click to toggle source
# File lib/osheet/workbook_element.rb, line 73 def <<(partial) if (key = verify(partial)) push(key, partial) end end
get(name)
click to toggle source
return the named partial
# File lib/osheet/workbook_element.rb, line 80 def get(name) lookup(key(name.to_s)) end
Private Instance Methods
key(name)
click to toggle source
# File lib/osheet/workbook_element.rb, line 110 def key(name) name.to_s end
lookup(key)
click to toggle source
# File lib/osheet/workbook_element.rb, line 86 def lookup(key) self[key] end
partial_key(partial)
click to toggle source
# File lib/osheet/workbook_element.rb, line 106 def partial_key(partial) key(partial.instance_variable_get("@name")) end
push(key, partial)
click to toggle source
push the partial onto the key
# File lib/osheet/workbook_element.rb, line 91 def push(key, partial) self[key] = partial end
verify(partial)
click to toggle source
verify the partial, init and return the key
otherwise ArgumentError it up
# File lib/osheet/workbook_element.rb, line 97 def verify(partial) unless partial.kind_of?(Partial) raise ArgumentError, 'you can only push Osheet::Partial objs to the partial set' end pkey = partial_key(partial) self[pkey] ||= nil pkey end