Class: Creeker::Sheet
Instance Attribute Summary collapse
-
#book ⇒ Object
readonly
Returns the value of attribute book.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rid ⇒ Object
readonly
Returns the value of attribute rid.
-
#sheetid ⇒ Object
readonly
Returns the value of attribute sheetid.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#visible ⇒ Object
readonly
Returns the value of attribute visible.
Instance Method Summary collapse
-
#images_at(cell) ⇒ Object
Extracts images for a cell to a temporary folder.
-
#initialize(book, name, sheetid, state, visible, rid, sheetfile) ⇒ Sheet
constructor
A new instance of Sheet.
-
#rows ⇒ Object
Provides an Enumerator that returns a hash representing each row.
-
#rows_with_meta_data ⇒ Object
Provides an Enumerator that returns a hash representing each row.
-
#with_images ⇒ Object
Preloads images info (coordinates and paths) from related drawing.xml and drawing rels.
Methods included from Utils
#expand_to_rels_path, #file_exist?, #parse_xml
Constructor Details
#initialize(book, name, sheetid, state, visible, rid, sheetfile) ⇒ Sheet
Returns a new instance of Sheet.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/creeker/sheet.rb', line 17 def initialize book, name, sheetid, state, visible, rid, sheetfile @book = book @name = name @sheetid = sheetid @visible = visible @rid = rid @state = state @sheetfile = sheetfile @images_present = false end |
Instance Attribute Details
#book ⇒ Object (readonly)
Returns the value of attribute book.
8 9 10 |
# File 'lib/creeker/sheet.rb', line 8 def book @book end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
8 9 10 |
# File 'lib/creeker/sheet.rb', line 8 def index @index end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/creeker/sheet.rb', line 8 def name @name end |
#rid ⇒ Object (readonly)
Returns the value of attribute rid.
8 9 10 |
# File 'lib/creeker/sheet.rb', line 8 def rid @rid end |
#sheetid ⇒ Object (readonly)
Returns the value of attribute sheetid.
8 9 10 |
# File 'lib/creeker/sheet.rb', line 8 def sheetid @sheetid end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
8 9 10 |
# File 'lib/creeker/sheet.rb', line 8 def state @state end |
#visible ⇒ Object (readonly)
Returns the value of attribute visible.
8 9 10 |
# File 'lib/creeker/sheet.rb', line 8 def visible @visible end |
Instance Method Details
#images_at(cell) ⇒ Object
Extracts images for a cell to a temporary folder. Returns array of Pathnames for the cell. Returns nil if images asre not found for the cell or images were not preloaded with #with_images.
45 46 47 |
# File 'lib/creeker/sheet.rb', line 45 def images_at(cell) @drawing.images_at(cell) if @images_present end |
#rows ⇒ Object
Provides an Enumerator that returns a hash representing each row. The key of the hash is the Cell id and the value is the value of the cell.
52 53 54 |
# File 'lib/creeker/sheet.rb', line 52 def rows rows_generator end |
#rows_with_meta_data ⇒ Object
Provides an Enumerator that returns a hash representing each row. The hash contains meta data of the row and a ‘cells’ embended hash which contains the cell contents.
59 60 61 |
# File 'lib/creeker/sheet.rb', line 59 def rows_generator true end |
#with_images ⇒ Object
Preloads images info (coordinates and paths) from related drawing.xml and drawing rels. Must be called before #rows method if you want to have images included. Returns self so you can chain the calls (sheet.with_images.rows).
32 33 34 35 36 37 38 39 |
# File 'lib/creeker/sheet.rb', line 32 def with_images @drawingfile = extract_drawing_filepath if @drawingfile @drawing = Creeker::Drawing.new(@book, @drawingfile.sub('..', 'xl')) @images_present = @drawing.has_images? end self end |