Class: RODF::StyleSection

Inherits:
Object
  • Object
show all
Defined in:
lib/rodf/style_section.rb

Instance Method Summary collapse

Constructor Details

#initialize(type, second = {}) ⇒ StyleSection

Returns a new instance of StyleSection.



3
4
5
6
7
8
9
10
11
# File 'lib/rodf/style_section.rb', line 3

def initialize(type, second = {})
  @type = type

  if second.instance_of?(Hash)
    @elem_attrs = make_element_attributes(second)
  else
    @content, @elem_attrs = second, {}
  end
end

Instance Method Details

#make_element_attributes(opts) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rodf/style_section.rb', line 17

def make_element_attributes(opts)
  attrs = {}

  attrs['number:decimal-places'] = opts[:decimal_places] unless opts[:decimal_places].nil?

  attrs['number:grouping'] = opts[:grouping] unless opts[:grouping].nil?

  attrs['number:min-integer-digits'] = opts[:min_integer_digits] unless opts[:min_integer_digits].nil?

  attrs['number:style'] = opts[:style] unless opts[:style].nil?

  attrs['number:textual'] = opts[:textual] unless opts[:textual].nil?

  attrs
end

#xmlObject



13
14
15
# File 'lib/rodf/style_section.rb', line 13

def xml
  Builder::XmlMarkup.new.number @type, @content, @elem_attrs
end