Sha256: d53adc1aab60ab81636d725e00e701b3ad83c0ddcc3a5187500f083297aa5c71

Contents?: true

Size: 940 Bytes

Versions: 5

Compression:

Stored size: 940 Bytes

Contents

require "open_xml_package"

module Rocx
  class Package
    attr_reader :content_types,
                :document,
                :global_rels,
                :rels,
                :settings,
                :styles

    def initialize
      @content_types = Rocx::Parts::ContentTypes.new
      @document = Rocx::Parts::Document.new
      @global_rels = Rocx::Parts::GlobalRels.new
      @rels = Rocx::Parts::Rels.new
      @settings = Rocx::Parts::Settings.new
      @styles = Rocx::Parts::Styles.new
    end

    def save(path)
      package = OpenXmlPackage.new
      package.add_part "_rels/.rels", global_rels
      package.add_part "[Content_Types].xml", content_types
      package.add_part "word/_rels/document.xml.rels", rels
      package.add_part "word/document.xml", document
      package.add_part "word/settings.xml", settings
      package.add_part "word/styles.xml", styles
      package.write_to path
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rocx-0.7.0 lib/rocx/package.rb
rocx-0.6.0 lib/rocx/package.rb
rocx-0.5.8 lib/rocx/package.rb
rocx-0.5.7 lib/rocx/package.rb
rocx-0.5.6 lib/rocx/package.rb