module Workbook::Modules::RawObjectsStorage
Adds support for storing raw objects, used in e.g. Format
and Template
Public Instance Methods
add_raw(raw_object, options={})
click to toggle source
A raw is a 'raw' object, representing a workbook, or cell, or whatever… in a particular format (defined by its class)
# File lib/workbook/modules/raw_objects_storage.rb, line 11 def add_raw raw_object, options={} class_of_obj = options[:raw_object_class] ? options[:raw_object_class] : raw_object.class raws[class_of_obj]=raw_object end
available_raws()
click to toggle source
Lists the classes for which raws are available @return [Array<Object>] array with the classes available
# File lib/workbook/modules/raw_objects_storage.rb, line 35 def available_raws raws.keys end
has_raw_for?(raw_object_class)
click to toggle source
Returns true if there is a template for a certain class, otherwise false
# File lib/workbook/modules/raw_objects_storage.rb, line 17 def has_raw_for? raw_object_class available_raws.include? raw_object_class end
raws()
click to toggle source
Return all raw data references
# File lib/workbook/modules/raw_objects_storage.rb, line 40 def raws @raws = {} unless defined? @raws @raws end
remove_all_raws!()
click to toggle source
Remove all raw data references
# File lib/workbook/modules/raw_objects_storage.rb, line 29 def remove_all_raws! @raws = {} end
return_raw_for(raw_object_class)
click to toggle source
Returns raw data stored for a type of raw object (if available) @param [Class] raw_object_class (e.g. Spreadsheet::Format for the Spreadsheet-gem)
# File lib/workbook/modules/raw_objects_storage.rb, line 23 def return_raw_for raw_object_class raws.each { |tc,t| return t if tc == raw_object_class} return nil end