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.



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

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



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

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



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

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