Class: OOXML::Excel::Sheet::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxml_excel/sheet.rb,
lib/ooxml_excel/sheet.rb

Defined Under Namespace

Classes: BlankCell, Cell

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ Row

Returns a new instance of Row.



149
150
151
# File 'lib/ooxml_excel/sheet.rb', line 149

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

Instance Attribute Details

#cellsObject

Returns the value of attribute cells.



147
148
149
# File 'lib/ooxml_excel/sheet.rb', line 147

def cells
  @cells
end

#idObject

Returns the value of attribute id.



147
148
149
# File 'lib/ooxml_excel/sheet.rb', line 147

def id
  @id
end

#spansObject

Returns the value of attribute spans.



147
148
149
# File 'lib/ooxml_excel/sheet.rb', line 147

def spans
  @spans
end

Class Method Details

.load_from_node(row_node, shared_strings, styles) ⇒ Object



162
163
164
165
166
# File 'lib/ooxml_excel/sheet.rb', line 162

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| Row::Cell.load_from_node(cell_node, shared_strings, styles) } )
end

Instance Method Details

#[](id) ⇒ Object



153
154
155
156
157
158
159
160
# File 'lib/ooxml_excel/sheet.rb', line 153

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