Class: ODF::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/odf/property.rb

Constant Summary collapse

PROPERTY_NAMES =
{:cell => 'style:table-cell-properties',
:text => 'style:text-properties',
:column => 'style:table-column-properties'}

Instance Method Summary collapse

Constructor Details

#initialize(type, specs = {}) ⇒ Property

Returns a new instance of Property.



27
28
29
30
# File 'lib/odf/property.rb', line 27

def initialize(type, specs={})
  @name = PROPERTY_NAMES[type]
  @specs = specs.map { |k, v| [k.to_s, v] }
end

Instance Method Details

#xmlObject



32
33
34
35
36
37
38
# File 'lib/odf/property.rb', line 32

def xml
  specs = @specs.inject({}) do |acc, kv|
    prefix = 'column-width' == kv.first ? 'style' : 'fo'
    acc.merge prefix + ':' + kv.first => kv.last
  end
  Builder::XmlMarkup.new.tag! @name, specs
end