Class: ODF::Style
Direct Known Subclasses
Constant Summary collapse
- FAMILIES =
{:cell => 'table-cell', :column => 'table-column'}
Instance Method Summary collapse
-
#initialize(name = '', opts = {}, node_tag = 'style:style') ⇒ Style
constructor
A new instance of Style.
- #make_element_attributes(name, opts) ⇒ Object
- #to_s ⇒ Object
- #xml ⇒ Object
Methods inherited from Container
Constructor Details
#initialize(name = '', opts = {}, node_tag = 'style:style') ⇒ Style
Returns a new instance of Style.
30 31 32 33 |
# File 'lib/odf/style.rb', line 30 def initialize(name='', opts={}, node_tag='style:style') @name, @node_tag = name, node_tag @elem_attrs = make_element_attributes(@name, opts) end |
Instance Method Details
#make_element_attributes(name, opts) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/odf/style.rb', line 41 def make_element_attributes(name, opts) attrs = { 'style:name' => name, 'style:family' => (FAMILIES[opts[:family]] || 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['style:master-page-name'] = opts[:master_page] unless opts[:master_page].nil? attrs end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/odf/style.rb', line 51 def to_s @name end |
#xml ⇒ Object
35 36 37 38 39 |
# File 'lib/odf/style.rb', line 35 def xml Builder::XmlMarkup.new.tag!(@node_tag, @elem_attrs) do |xml| xml << properties_xml end end |