Class: DocxTools::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/docx_tools/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath) ⇒ Document

read the filepath and parse it as a zip file



8
9
10
# File 'lib/docx_tools/document.rb', line 8

def initialize(filepath)
  self.zip = Zip::File.open(filepath)
end

Instance Attribute Details

#zipObject

the stored zip file (docx)



5
6
7
# File 'lib/docx_tools/document.rb', line 5

def zip
  @zip
end

Instance Method Details

#entriesObject

the entries contained within the zip



13
14
15
# File 'lib/docx_tools/document.rb', line 13

def entries
  zip.entries
end

#get(filename) ⇒ Object

read the file within the zip at the given filename



18
19
20
# File 'lib/docx_tools/document.rb', line 18

def get(filename)
  Nokogiri::XML(zip.read(filename))
end