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.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rodf/row.rb', line 5

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

Instance Method Details

#add_cells(*elements) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/rodf/row.rb', line 39

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



23
24
25
26
27
28
29
# File 'lib/rodf/row.rb', line 23

def cell(*args, &block)
  x = Cell.new(*args, &block)

  cells << x

  return x
end

#cellsObject



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

def cells
  @cells ||= []
end

#cells_xmlObject



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

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

#style=(style_name) ⇒ Object



35
36
37
# File 'lib/rodf/row.rb', line 35

def style=(style_name)
  @elem_attrs['table:style-name'] = style_name
end

#xmlObject



49
50
51
52
53
# File 'lib/rodf/row.rb', line 49

def xml
  Builder::XmlMarkup.new.tag! 'table:table-row', @elem_attrs do |xml|
    xml << cells_xml
  end
end