Module: Workbook::Modules::RawObjectsStorage

Included in:
Format, Template
Defined in:
lib/workbook/modules/raw_objects_storage.rb

Overview

Adds support for storing raw objects, used in e.g. Format and Template

Instance Method Summary collapse

Instance Method Details

#add_raw(raw_object) ⇒ Object

A raw is a 'raw' object, representing a workbook, or cell, or whatever… in a particular format (defined by its class)



8
9
10
# File 'lib/workbook/modules/raw_objects_storage.rb', line 8

def add_raw raw_object
  raws[raw_object.class]=raw_object
end

#available_rawsObject

Lists the classes for which raws are available



31
32
33
# File 'lib/workbook/modules/raw_objects_storage.rb', line 31

def available_raws
  raws.keys
end

#has_raw_for?(raw_object_class) ⇒ Boolean

Returns true if there is a template for a certain class, otherwise false

Returns:

  • (Boolean)


13
14
15
# File 'lib/workbook/modules/raw_objects_storage.rb', line 13

def has_raw_for? raw_object_class
  available_raws.include? raw_object_class
end

#rawsObject

Return all raw data references



36
37
38
39
# File 'lib/workbook/modules/raw_objects_storage.rb', line 36

def raws
  @raws = {} unless defined? @raws
  @raws
end

#remove_all_raws!Object

Remove all raw data references



25
26
27
# File 'lib/workbook/modules/raw_objects_storage.rb', line 25

def remove_all_raws!
  @raws = {}
end

#return_raw_for(raw_object_class) ⇒ Object

Returns raw data stored for a type of raw object (if available)

Parameters:

  • raw_object_class (Class)

    (e.g. Spreadsheet::Format for the Spreadsheet-gem)



19
20
21
22
# File 'lib/workbook/modules/raw_objects_storage.rb', line 19

def return_raw_for raw_object_class
  raws.each { |tc,t| return t if tc == raw_object_class}
  return nil
end