Class: XLSX::Row

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(worksheet, row_number) ⇒ Row

Returns a new instance of Row.



30
31
32
33
34
35
36
# File 'lib/xlsx/row.rb', line 30

def initialize(worksheet, row_number)
  @worksheet = worksheet
  @row_number = row_number
  @cells = {}
  @min_col = 0
  @max_col = 0
end

Instance Attribute Details

#max_colObject (readonly)

Returns the value of attribute max_col.



28
29
30
# File 'lib/xlsx/row.rb', line 28

def max_col
  @max_col
end

#min_colObject (readonly)

Returns the value of attribute min_col.



28
29
30
# File 'lib/xlsx/row.rb', line 28

def min_col
  @min_col
end

#row_numberObject (readonly)

Returns the value of attribute row_number.



28
29
30
# File 'lib/xlsx/row.rb', line 28

def row_number
  @row_number
end

Instance Method Details

#[]=(col_number, value) ⇒ Object



38
39
40
41
42
43
# File 'lib/xlsx/row.rb', line 38

def []=(col_number, value)
  raise "Column number must be a non-negative integer." unless col_number.is_a?(Integer) && col_number >= 0
  @cells[col_number] = XLSX::Cell.new(@row_number, col_number, value)
  @min_col = col_number if col_number < @min_col
  @max_col = col_number if col_number > @max_col
end

#eachObject



45
46
47
48
49
# File 'lib/xlsx/row.rb', line 45

def each
  @cells.keys.sort.each do |col_no|
    yield @cells[col_no]
  end
end

#lastObject



51
52
53
# File 'lib/xlsx/row.rb', line 51

def last
  @cells[@cells.keys.sort.last]
end