Class: RODF::Row
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#style ⇒ Object
writeonly
Sets the attribute style.
Instance Method Summary collapse
- #add_cells(*elements) ⇒ Object
- #cell(*args, &block) ⇒ Object
- #cells ⇒ Object
- #cells_xml ⇒ Object
-
#initialize(number = 0, opts = {}) ⇒ Row
constructor
A new instance of Row.
- #xml ⇒ Object
Methods inherited from Container
Constructor Details
#initialize(number = 0, opts = {}) ⇒ Row
Returns a new instance of Row.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rodf/row.rb', line 6 def initialize(number=0, opts={}) @number = number @elem_attrs = {} @elem_attrs['table:style-name'] = opts[:style] unless opts[:style].nil? if opts[:attributes] @elem_attrs.merge!(opts[:attributes]) end super end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
3 4 5 |
# File 'lib/rodf/row.rb', line 3 def number @number end |
#style=(style_name) ⇒ Object (writeonly)
Sets the attribute style
4 5 6 |
# File 'lib/rodf/row.rb', line 4 def style=(value) @style = value end |
Instance Method Details
#add_cells(*elements) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/rodf/row.rb', line 40 def add_cells(*elements) if elements.first.is_a?(Array) elements = elements.first end elements.each do |element| cell(element) end end |
#cell(*args, &block) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/rodf/row.rb', line 24 def cell(*args, &block) x = Cell.new(*args, &block) cells << x return x end |
#cells ⇒ Object
20 21 22 |
# File 'lib/rodf/row.rb', line 20 def cells @cells ||= [] end |
#cells_xml ⇒ Object
32 33 34 |
# File 'lib/rodf/row.rb', line 32 def cells_xml cells.map(&:xml).join end |
#xml ⇒ Object
50 51 52 53 54 |
# File 'lib/rodf/row.rb', line 50 def xml Builder::XmlMarkup.new.tag! 'table:table-row', @elem_attrs do |xml| xml << cells_xml end end |