Class: OpenXml::Docx::Properties::ContainerProperty
Constant Summary
AttributeBuilder::VALID_THEME_COLORS, AttributeBuilder::VALID_TYPES
Instance Attribute Summary
Attributes inherited from BaseProperty
#value
Class Method Summary
collapse
Instance Method Summary
collapse
#attributes, included
#default_name, #default_namespace, #default_tag, #name, name, namespace, #namespace, #tag, tag, tag_is_one_of
Constructor Details
Returns a new instance of ContainerProperty.
20
21
22
|
# File 'lib/openxml/docx/properties/container_property.rb', line 20
def initialize
@children = []
end
|
Class Method Details
.child_class(*args) ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/openxml/docx/properties/container_property.rb', line 9
def child_class(*args)
if args.any?
prop_name = args.first.to_s.split(/_/).map(&:capitalize).join child_class_obj = OpenXml::Docx::Properties.const_get prop_name
@child_class = OpenXml::Docx::Properties.const_get prop_name
end
@child_class
end
|
Instance Method Details
#<<(child) ⇒ Object
24
25
26
27
|
# File 'lib/openxml/docx/properties/container_property.rb', line 24
def <<(child)
raise ArgumentError, invalid_child_message unless valid_child?(child)
children << child
end
|
#each(*args, &block) ⇒ Object
29
30
31
|
# File 'lib/openxml/docx/properties/container_property.rb', line 29
def each(*args, &block)
children.each *args, &block
end
|
#render? ⇒ Boolean
33
34
35
|
# File 'lib/openxml/docx/properties/container_property.rb', line 33
def render?
!children.length.zero?
end
|
#to_xml(xml) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/openxml/docx/properties/container_property.rb', line 37
def to_xml(xml)
return unless render?
xml["w"].public_send(tag, xml_attributes) {
each { |child| child.to_xml(xml) }
}
end
|