class Cartos::Google::Sheet
Constants
- ALPHABET
Public Class Methods
new(sheet)
click to toggle source
# File lib/cartos/google/sheet.rb, line 45 def initialize(sheet) @sheet = sheet @last_rows = {} end
Public Instance Methods
column_letter_to_integer(column)
click to toggle source
# File lib/cartos/google/sheet.rb, line 70 def column_letter_to_integer(column) ALPHABET.index(column) + 1 end
last_row(column)
click to toggle source
# File lib/cartos/google/sheet.rb, line 62 def last_row(column) @last_rows[ensure_column_as_number column] ||= 1 end
push_row(column, value)
click to toggle source
# File lib/cartos/google/sheet.rb, line 50 def push_row(column, value) column_number = ensure_column_as_number column result = set_row (self.last_row column), column_number, value result end
row_range(column, first, last)
click to toggle source
# File lib/cartos/google/sheet.rb, line 74 def row_range(column, first, last) "#{column}#{first}:#{column}#{last}" end
save()
click to toggle source
# File lib/cartos/google/sheet.rb, line 66 def save @sheet.save end
set_row(row, column, value)
click to toggle source
# File lib/cartos/google/sheet.rb, line 56 def set_row(row, column, value) @sheet[row, column] = value @last_rows[column] = row + 1 [row, column] end
Private Instance Methods
ensure_column_as_number(column)
click to toggle source
# File lib/cartos/google/sheet.rb, line 79 def ensure_column_as_number(column) case column when String column_letter_to_integer column when Fixnum column end end