Class: RODF::Row

Inherits:
Container show all
Defined in:
lib/rodf/row.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Container

create

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

#numberObject (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

Parameters:

  • value

    the value to set the attribute style to.



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

#cellsObject



20
21
22
# File 'lib/rodf/row.rb', line 20

def cells
  @cells ||= []
end

#cells_xmlObject



32
33
34
# File 'lib/rodf/row.rb', line 32

def cells_xml
  cells.map(&:xml).join
end

#xmlObject



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