Class: Rocx::Package

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePackage

Returns a new instance of Package.



12
13
14
15
16
17
18
19
# File 'lib/rocx/package.rb', line 12

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

Instance Attribute Details

#content_typesObject (readonly)

Returns the value of attribute content_types.



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

def content_types
  @content_types
end

#documentObject (readonly)

Returns the value of attribute document.



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

def document
  @document
end

#global_relsObject (readonly)

Returns the value of attribute global_rels.



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

def global_rels
  @global_rels
end

#relsObject (readonly)

Returns the value of attribute rels.



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

def rels
  @rels
end

#settingsObject (readonly)

Returns the value of attribute settings.



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

def settings
  @settings
end

#stylesObject (readonly)

Returns the value of attribute styles.



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

def styles
  @styles
end

Instance Method Details

#save(path) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/rocx/package.rb', line 21

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