class GoogleCells::CellSelector::RowSelector
Constants
- DEFAULT_BATCH_SIZE
Public Instance Methods
all()
click to toggle source
# File lib/google_cells/cell_selector/row_selector.rb, line 25 def all @rows = [] self.find_each(batch_size:@max_row - @min_row){|r| @rows << r} @rows end
each() { |c| ... }
click to toggle source
# File lib/google_cells/cell_selector/row_selector.rb, line 21 def each all.each{|c| yield c} end
find_each(opts={}) { |row(cells:cells, number:rnum, worksheet:worksheet)| ... }
click to toggle source
# File lib/google_cells/cell_selector/row_selector.rb, line 8 def find_each(opts={}, &block) size = (opts[:batch_size] || DEFAULT_BATCH_SIZE).to_i rnum = @min_row loop do last = [rnum + size, @max_row].min break if rnum > last get_cells(rnum, last).each do |cells| yield Row.new(cells:cells, number:rnum, worksheet:worksheet) rnum += 1 end end end
first()
click to toggle source
# File lib/google_cells/cell_selector/row_selector.rb, line 31 def first all.first end
from(num)
click to toggle source
# File lib/google_cells/cell_selector/row_selector.rb, line 35 def from(num) @min_row = num.to_i self end
to(num)
click to toggle source
# File lib/google_cells/cell_selector/row_selector.rb, line 40 def to(num) @max_row = num.to_i self end
Private Instance Methods
get_cells(start, last)
click to toggle source
# File lib/google_cells/cell_selector/row_selector.rb, line 47 def get_cells(start, last) cells = [] each_entry(worksheet.cells_uri, 'return-empty' => 'true', 'min-row' => start.to_s, 'max-row' => last.to_s) do |entry| args = parse_from_entry(entry) cell = Cell.new(args) cells[cell.row - start] ||= [] cells[cell.row - start][cell.col - 1] = cell end cells end