Class: OpenXmlPackage

Inherits:
Object
  • Object
show all
Defined in:
lib/open_xml_package.rb,
lib/open_xml_package/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOpenXmlPackage

Returns a new instance of OpenXmlPackage.



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

def initialize
  @parts = {}
end

Instance Attribute Details

#partsObject (readonly)

Returns the value of attribute parts.



6
7
8
# File 'lib/open_xml_package.rb', line 6

def parts
  @parts
end

Instance Method Details

#add_part(path, part) ⇒ Object



12
13
14
# File 'lib/open_xml_package.rb', line 12

def add_part(path, part)
  parts[path] = part
end

#write_to(path) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/open_xml_package.rb', line 16

def write_to(path)
  Zip::OutputStream.open(path) do |io|
    parts.each do |path, part|
      io.put_next_entry path
      io.write part.read
    end
  end
end