class Spodunk::Connection::Base

Attributes

session[R]
spreadsheet[R]

Public Class Methods

new(*args) click to toggle source

the interface between Hash objects and Google Spreadsheets

# File lib/spodunk/connection.rb, line 7
def initialize(*args)
  @tables = {}
end

Public Instance Methods

load_spreadsheet(*args) click to toggle source
# File lib/spodunk/connection.rb, line 24
def load_spreadsheet(*args);end
load_table(title) click to toggle source
# 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) click to toggle source
# File lib/spodunk/connection.rb, line 26
def real_tables(tid)
  if(tid.is_a?(Spodunk::Table))
    tid = tid.title
  end

  if t = @tables[tid]
    return t[:real]
  end
end
save_cell(table_id, real_row_idx, real_col_idx, val) click to toggle source

arr_xy is something like [2,3] (row 2, col 3)

expects arr_xy to contain offset-applied row and col index
# File lib/spodunk/connection.rb, line 69
def save_cell(table_id, real_row_idx, real_col_idx, val)
  # abstract
end
save_row(table_id, row) click to toggle source
# File lib/spodunk/connection.rb, line 48
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) click to toggle source
# File lib/spodunk/connection.rb, line 57
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) click to toggle source
# File lib/spodunk/connection.rb, line 44
def table(tid)
  tables(tid)
end
tables(tid) click to toggle source
# File lib/spodunk/connection.rb, line 36
def tables(tid)
  if(tid.is_a?(Spodunk::Table))
    return tid
  elsif t = @tables[tid]
    return t[:podunk]
  end
end

Protected Instance Methods

fetch_real_table_object(*args) click to toggle source
# File lib/spodunk/connection.rb, line 79
def fetch_real_table_object(*args); end
init_podunk_table(*args) click to toggle source
# File lib/spodunk/connection.rb, line 78
def init_podunk_table(*args); end