Class: Spodunk::Connection::Base
- Inherits:
-
Object
- Object
- Spodunk::Connection::Base
- Defined in:
- lib/spodunk/connection.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#spreadsheet ⇒ Object
readonly
Returns the value of attribute spreadsheet.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Base
constructor
the interface between Hash objects and Google Spreadsheets.
- #load_spreadsheet(*args) ⇒ Object
- #load_table(title) ⇒ Object
- #real_tables(tid) ⇒ Object
-
#save_cell(table_id, real_row_idx, real_col_idx, val) ⇒ Object
arr_xy is something like [2,3] (row 2, col 3) expects arr_xy to contain offset-applied row and col index.
- #save_row(table_id, row) ⇒ Object
- #save_table(table_id) ⇒ Object
- #table(tid) ⇒ Object
- #tables(tid) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Base
the interface between Hash objects and Google Spreadsheets
7 8 9 |
# File 'lib/spodunk/connection.rb', line 7 def initialize(*args) @tables = {} end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
4 5 6 |
# File 'lib/spodunk/connection.rb', line 4 def session @session end |
#spreadsheet ⇒ Object (readonly)
Returns the value of attribute spreadsheet.
4 5 6 |
# File 'lib/spodunk/connection.rb', line 4 def spreadsheet @spreadsheet end |
Instance Method Details
#load_spreadsheet(*args) ⇒ Object
24 |
# File 'lib/spodunk/connection.rb', line 24 def load_spreadsheet(*args);end |
#load_table(title) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/spodunk/connection.rb', line 13 def load_table(title) unless title.nil? @tables[title] = {} @tables[title][:real] = real_t = fetch_real_table_object(title) @tables[title][:podunk] = init_podunk_table(real_t, title: title) end end |
#real_tables(tid) ⇒ Object
26 27 28 29 30 |
# File 'lib/spodunk/connection.rb', line 26 def real_tables(tid) if t = @tables[tid] return t[:real] end end |
#save_cell(table_id, real_row_idx, real_col_idx, val) ⇒ Object
arr_xy is something like [2,3] (row 2, col 3)
expects arr_xy to contain offset-applied row and col index
63 64 65 |
# File 'lib/spodunk/connection.rb', line 63 def save_cell(table_id, real_row_idx, real_col_idx, val) # abstract end |
#save_row(table_id, row) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/spodunk/connection.rb', line 42 def save_row(table_id, row) pt = tables(table_id) row_idx = pt.real_row_index(row) row.itemized_changes.each_pair do |col_idx, val| save_cell(table_id, row_idx, col_idx, val) end end |
#save_table(table_id) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/spodunk/connection.rb', line 51 def save_table(table_id) pt = tables(table_id) # expects itemized_changes to be {[2,3] => 4} # with row_offset and col_offset already applied pt.itemized_changes.each_pair do |(r, c), val| save_cell(table_id, r, c, val) end end |
#table(tid) ⇒ Object
38 39 40 |
# File 'lib/spodunk/connection.rb', line 38 def table(tid) tables(tid) end |
#tables(tid) ⇒ Object
32 33 34 35 36 |
# File 'lib/spodunk/connection.rb', line 32 def tables(tid) if t = @tables[tid] return t[:podunk] end end |