Class: OoxmlParser::FileReference
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::FileReference
- Defined in:
- lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb
Overview
Class for storing image data
Instance Attribute Summary collapse
-
#content ⇒ String
Content of file.
-
#path ⇒ String
Path to file.
-
#resource_id ⇒ String
Id of resource.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
Methods inherited from OOXMLDocumentObject
#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, #initialize, unzip_file, #with_data?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
This class inherits a constructor from OoxmlParser::OOXMLDocumentObject
Instance Attribute Details
#content ⇒ String
Returns content of file.
9 10 11 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb', line 9 def content @content end |
#path ⇒ String
Returns path to file.
7 8 9 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb', line 7 def path @path end |
#resource_id ⇒ String
Returns id of resource.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb', line 5 def resource_id @resource_id end |
Instance Method Details
#parse(node) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb', line 11 def parse(node) node.attributes.each do |key, value| case key when 'embed', 'id', 'link' @resource_id = value.value end end return self unless @resource_id return self if @resource_id.empty? @path = OOXMLDocumentObject.get_link_from_rels(@resource_id) if !@path || @path.empty? warn "Cant find path to media file by id: #{@resource_id}" return self end return self if @path == 'NULL' full_path_to_file = OOXMLDocumentObject.path_to_folder + OOXMLDocumentObject.root_subfolder + @path.gsub('..', '') if File.exist?(full_path_to_file) @content = IO.binread(full_path_to_file) else warn "Couldn't find #{full_path_to_file} file on filesystem. Possible problem in original document" end self end |