Class: Cartos::Google::Sheet
- Inherits:
-
Object
- Object
- Cartos::Google::Sheet
- Defined in:
- lib/cartos/google/sheet.rb
Defined Under Namespace
Classes: Formulas
Constant Summary collapse
- ALPHABET =
"A".upto("Z").to_a
Instance Method Summary collapse
- #column_letter_to_integer(column) ⇒ Object
-
#initialize(sheet) ⇒ Sheet
constructor
A new instance of Sheet.
- #last_row(column) ⇒ Object
- #push_row(column, value) ⇒ Object
- #row_range(column, first, last) ⇒ Object
- #save ⇒ Object
- #set_row(row, column, value) ⇒ Object
Constructor Details
#initialize(sheet) ⇒ Sheet
Returns a new instance of Sheet.
45 46 47 48 |
# File 'lib/cartos/google/sheet.rb', line 45 def initialize(sheet) @sheet = sheet @last_rows = {} end |
Instance Method Details
#column_letter_to_integer(column) ⇒ Object
70 71 72 |
# File 'lib/cartos/google/sheet.rb', line 70 def column_letter_to_integer(column) ALPHABET.index(column) + 1 end |
#last_row(column) ⇒ Object
62 63 64 |
# 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) ⇒ Object
50 51 52 53 54 |
# 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) ⇒ Object
74 75 76 |
# File 'lib/cartos/google/sheet.rb', line 74 def row_range(column, first, last) "#{column}#{first}:#{column}#{last}" end |
#save ⇒ Object
66 67 68 |
# File 'lib/cartos/google/sheet.rb', line 66 def save @sheet.save end |
#set_row(row, column, value) ⇒ Object
56 57 58 59 60 |
# 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 |