Class: RODF::Style
Constant Summary
collapse
- FAMILIES =
{
"cell" => 'table-cell',
"column" => 'table-column',
"row" => 'table-row',
}
Instance Method Summary
collapse
Methods inherited from Container
create
Constructor Details
#initialize(name = '', opts = {}, node_tag = 'style:style') ⇒ Style
Returns a new instance of Style.
9
10
11
12
13
14
15
|
# File 'lib/rodf/style.rb', line 9
def initialize(name='', opts={}, node_tag='style:style')
super
@name, @node_tag = name, node_tag
@elem_attrs = make_element_attributes(@name, opts)
end
|
Instance Method Details
#add_properties(*elements) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/rodf/style.rb', line 58
def add_properties(*elements)
if elements.first.is_a?(Array)
elements = elements.first
end
elements.each do |element|
property(element)
end
end
|
#make_element_attributes(name, opts) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rodf/style.rb', line 23
def make_element_attributes(name, opts)
attrs = {
'style:name' => name,
'style:family' => (FAMILIES[opts[:family].to_s] || opts[:family]),
}
attrs['style:data-style-name'] = opts[:data_style] unless opts[:data_style].nil?
attrs['style:parent-style-name'] = opts[:parent].to_s unless opts[:parent].nil?
attrs['style:master-page-name'] = opts[:master_page] unless opts[:master_page].nil?
attrs
end
|
#properties ⇒ Object
42
43
44
|
# File 'lib/rodf/style.rb', line 42
def properties
@properties ||= []
end
|
#properties_xml ⇒ Object
54
55
56
|
# File 'lib/rodf/style.rb', line 54
def properties_xml
properties.map(&:xml).join
end
|
#property(*args, &block) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/rodf/style.rb', line 46
def property(*args, &block)
x = Property.new(*args, &block)
properties << x
return x
end
|
#to_s ⇒ Object
38
39
40
|
# File 'lib/rodf/style.rb', line 38
def to_s
@name
end
|
#xml ⇒ Object
17
18
19
20
21
|
# File 'lib/rodf/style.rb', line 17
def xml
Builder::XmlMarkup.new.tag!(@node_tag, @elem_attrs) do |xml|
xml << properties_xml
end
end
|