Class: Docxtor2::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/docxtor2.rb,
lib/docxtor2/package.rb

Defined Under Namespace

Classes: Document, Part

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parts, document) ⇒ Package

Returns a new instance of Package.



5
6
7
8
# File 'lib/docxtor2/package.rb', line 5

def initialize(parts, document)
  @parts = parts
  @parts[Known::Parts::DOCUMENT] = document
end

Instance Attribute Details

#partsObject (readonly)

Returns the value of attribute parts.



3
4
5
# File 'lib/docxtor2/package.rb', line 3

def parts
  @parts
end

Instance Method Details

#save(filepath) ⇒ Object



10
11
12
13
14
# File 'lib/docxtor2/package.rb', line 10

def save(filepath)
  Zip::ZipOutputStream.open(filepath) do |ostream|
    write_parts(ostream)
  end
end

#to_streamObject



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

def to_stream
  ostream = Zip::ZipOutputStream.new("streamed", true)
  write_parts(ostream)
  string_io = ostream.close_buffer
  string_io.rewind
  string_io
end