Class: OOXL::Row

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ooxl/xl_objects/row.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ Row

Returns a new instance of Row.



6
7
8
# File 'lib/ooxl/xl_objects/row.rb', line 6

def initialize(**attrs)
  attrs.each { |property, value| send("#{property}=", value)}
end

Instance Attribute Details

#cellsObject

Returns the value of attribute cells.



4
5
6
# File 'lib/ooxl/xl_objects/row.rb', line 4

def cells
  @cells
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/ooxl/xl_objects/row.rb', line 4

def id
  @id
end

#spansObject

Returns the value of attribute spans.



4
5
6
# File 'lib/ooxl/xl_objects/row.rb', line 4

def spans
  @spans
end

Class Method Details

.load_from_node(row_node, shared_strings, styles) ⇒ Object



23
24
25
26
27
# File 'lib/ooxl/xl_objects/row.rb', line 23

def self.load_from_node(row_node, shared_strings, styles)
  new(id: row_node.attributes["r"].try(:value),
      spans: row_node.attributes["spans"].try(:value),
      cells: row_node.xpath('c').map {  |cell_node| OOXL::Cell.load_from_node(cell_node, shared_strings, styles) } )
end

Instance Method Details

#[](id) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/ooxl/xl_objects/row.rb', line 10

def [](id)
  cell = if id.is_a?(String)
    cells.find { |row| row.id == id}
  else
    cells[id]
  end
  (cell.present?) ? cell : BlankCell.new(id)
end

#eachObject



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

def each
  cells.each { |cell| yield cell }
end