Class: Sheetah::Backends::Wrapper
- Inherits:
-
Object
- Object
- Sheetah::Backends::Wrapper
show all
- Includes:
- Sheet
- Defined in:
- lib/sheetah/backends/wrapper.rb
Constant Summary
Constants included
from Sheet
Sheet::COL_CONVERTER
Instance Method Summary
collapse
Methods included from Sheet
col2int, included, int2col
Constructor Details
#initialize(table) ⇒ Wrapper
Returns a new instance of Wrapper.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/sheetah/backends/wrapper.rb', line 10
def initialize(table)
raise Error if table.nil?
@table = table
if (table_size = @table.size).positive?
= @table[0]
@rows_count = table_size - 1
@cols_count = .size
else
= []
@rows_count = 0
@cols_count = 0
end
end
|
Instance Method Details
#close ⇒ Object
52
53
54
|
# File 'lib/sheetah/backends/wrapper.rb', line 52
def close
end
|
26
27
28
29
30
31
32
33
34
|
# File 'lib/sheetah/backends/wrapper.rb', line 26
def
return to_enum(:each_header) { @cols_count } unless block_given?
1.upto(@cols_count) do |col|
yield .new(col: Sheet.int2col(col), value: [col - 1])
end
self
end
|
#each_row ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/sheetah/backends/wrapper.rb', line 36
def each_row
return to_enum(:each_row) unless block_given?
1.upto(@rows_count) do |row|
raw = @table[row]
value = Array.new(@cols_count) do |col_idx|
Cell.new(row: row, col: Sheet.int2col(col_idx + 1), value: raw[col_idx])
end
yield Row.new(row: row, value: value)
end
self
end
|