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: Cell

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ Row

Returns a new instance of Row.



137
138
139
# File 'lib/ooxml_excel/sheet.rb', line 137

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

Instance Attribute Details

#cellsObject

Returns the value of attribute cells.



135
136
137
# File 'lib/ooxml_excel/sheet.rb', line 135

def cells
  @cells
end

#idObject

Returns the value of attribute id.



135
136
137
# File 'lib/ooxml_excel/sheet.rb', line 135

def id
  @id
end

#spansObject

Returns the value of attribute spans.



135
136
137
# File 'lib/ooxml_excel/sheet.rb', line 135

def spans
  @spans
end

Class Method Details

.load_from_node(row_node, shared_strings) ⇒ Object



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

def self.load_from_node(row_node, shared_strings)
  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) } )
end

Instance Method Details

#[](id) ⇒ Object



141
142
143
144
145
146
147
# File 'lib/ooxml_excel/sheet.rb', line 141

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