Class: ODF::Property

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

Constant Summary collapse

PROPERTY_NAMES =
{:cell => 'table-cell-properties',
:text => 'text-properties',
:column => 'table-column-properties',
:row => 'table-row-properties',
:conditional => 'map'}
TRANSLATED_SPECS =
[:border_color, :border_style, :border_width]
STYLE_ATTRIBUTES =
['column-width', 'rotation-angle', 'text-underline-type',
'tab-stop-distance', 'condition', 'apply-style-name',
'base-cell-address']

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Property.



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

def initialize(type, specs={})
  @name = 'style:' + (PROPERTY_NAMES[type] || "#{type}-properties")
  @specs = translate(specs).map { |k, v| [k.to_s, v] }
end

Instance Method Details

#xmlObject



38
39
40
41
42
43
44
# File 'lib/odf/property.rb', line 38

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