class Officedoc::Package::Raw

Attributes

stream[R]
zip_engine[R]

Public Class Methods

new( stream, zip_engine: ::Officedoc::Package::Raw::RubyZipEngine ) click to toggle source
# File lib/officedoc/package/raw.rb, line 10
def initialize( stream, zip_engine: ::Officedoc::Package::Raw::RubyZipEngine )
  @zip_engine = zip_engine
  @stream = stream
end

Public Instance Methods

document_type() click to toggle source
# File lib/officedoc/package/raw.rb, line 24
def document_type
  @document_type ||= get_document_type
end
file_names() click to toggle source
# File lib/officedoc/package/raw.rb, line 18
def file_names
  zip_file.entries.map(&:name)
end
parts() click to toggle source
# File lib/officedoc/package/raw.rb, line 21
def parts
  @parts ||= PartList.new zip_file
end

Private Instance Methods

get_document_type() click to toggle source
# File lib/officedoc/package/raw.rb, line 27
        def get_document_type
  # Example: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
  main_doc_parts = parts.of_type "document.main+xml", partial: true
  return "" if main_doc_parts.size != 1

  match = /.*\.(.*)\.document\.main\+xml/.match(main_doc_parts[0].type)
  match ? match[1] : ""
end
zip_file() click to toggle source
# File lib/officedoc/package/raw.rb, line 14
        def zip_file
  @zip_file ||= zip_engine.new(stream)
end