Class: Rocx::Parts::ContentTypes
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from BasePart
#build_standalone_xml, #build_xml, #read
Constructor Details
Returns a new instance of ContentTypes.
6
7
8
9
10
|
# File 'lib/rocx/parts/content_types.rb', line 6
def initialize
@defaults, @overrides = [], []
install_preset_defaults
install_preset_overrides
end
|
Instance Attribute Details
#defaults ⇒ Object
Returns the value of attribute defaults.
4
5
6
|
# File 'lib/rocx/parts/content_types.rb', line 4
def defaults
@defaults
end
|
#overrides ⇒ Object
Returns the value of attribute overrides.
4
5
6
|
# File 'lib/rocx/parts/content_types.rb', line 4
def overrides
@overrides
end
|
Instance Method Details
#default(extension, content_type) ⇒ Object
23
24
25
|
# File 'lib/rocx/parts/content_types.rb', line 23
def default(extension, content_type)
defaults << {"Extension" => extension, "ContentType" => content_type}
end
|
#install_preset_defaults ⇒ Object
12
13
14
15
16
|
# File 'lib/rocx/parts/content_types.rb', line 12
def install_preset_defaults
default "xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
default "rels", "application/vnd.openxmlformats-package.relationships+xml"
default "png", "image/png"
end
|
#install_preset_overrides ⇒ Object
18
19
20
21
|
# File 'lib/rocx/parts/content_types.rb', line 18
def install_preset_overrides
override "/word/styles.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"
override "/word/settings.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"
end
|
#override(part_name, content_type) ⇒ Object
27
28
29
|
# File 'lib/rocx/parts/content_types.rb', line 27
def override(part_name, content_type)
overrides << {"PartName" => part_name, "ContentType" => content_type}
end
|
#to_xml ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/rocx/parts/content_types.rb', line 31
def to_xml
build_xml do |xml|
xml.Types(xmlns: "http://schemas.openxmlformats.org/package/2006/content-types") {
defaults.each { |default| xml.Default(default) }
overrides.each { |override| xml.Override(override) }
}
end
end
|