Class: ODF::Style

Inherits:
Container show all
Defined in:
lib/odf/style.rb

Constant Summary collapse

FAMILIES =
{:cell => 'table-cell', :column => 'table-column'}

Instance Method Summary collapse

Methods inherited from Container

contains, create

Constructor Details

#initialize(name = '', opts = {}) ⇒ Style

Returns a new instance of Style.



30
31
32
33
# File 'lib/odf/style.rb', line 30

def initialize(name='', opts={})
  @name = name
  @elem_attrs = make_element_attributes(@name, opts)
end

Instance Method Details

#make_element_attributes(name, opts) ⇒ Object



41
42
43
44
45
46
# File 'lib/odf/style.rb', line 41

def make_element_attributes(name, opts)
  attrs = {'style:name' => name, 'style:family' => FAMILIES[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
end

#to_sObject



48
49
50
# File 'lib/odf/style.rb', line 48

def to_s
  @name
end

#xmlObject



35
36
37
38
39
# File 'lib/odf/style.rb', line 35

def xml
  Builder::XmlMarkup.new.style:style, @elem_attrs do |xml|
    xml << properties_xml
  end
end