Class: RgGen::SpreadsheetLoader::Spreadsheet::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/rggen/spreadsheet_loader/spreadsheet/row.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sheet, row) ⇒ Row

Returns a new instance of Row.



7
8
9
10
11
12
# File 'lib/rggen/spreadsheet_loader/spreadsheet/row.rb', line 7

def initialize(sheet, row)
  @file = sheet.file
  @sheet = sheet.sheet
  @row = row
  @cells = []
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



14
15
16
# File 'lib/rggen/spreadsheet_loader/spreadsheet/row.rb', line 14

def file
  @file
end

#rowObject (readonly)

Returns the value of attribute row.



16
17
18
# File 'lib/rggen/spreadsheet_loader/spreadsheet/row.rb', line 16

def row
  @row
end

#sheetObject (readonly)

Returns the value of attribute sheet.



15
16
17
# File 'lib/rggen/spreadsheet_loader/spreadsheet/row.rb', line 15

def sheet
  @sheet
end

Instance Method Details

#[](column) ⇒ Object



18
19
20
21
# File 'lib/rggen/spreadsheet_loader/spreadsheet/row.rb', line 18

def [](column)
  @cells[column] ||= EmptyCell.new(self, column)
  @cells[column]
end

#[]=(column, value) ⇒ Object



23
24
25
# File 'lib/rggen/spreadsheet_loader/spreadsheet/row.rb', line 23

def []=(column, value)
  @cells[column] = Cell.new(value, self, column)
end

#cells(from = 0, length = nil) ⇒ Object



27
28
29
# File 'lib/rggen/spreadsheet_loader/spreadsheet/row.rb', line 27

def cells(from = 0, length = nil)
  Array.new(length || (@cells.size - from)) { |i| self[from + i] }
end