Created
January 20, 2013 19:28
-
-
Save octosteve/4581047 to your computer and use it in GitHub Desktop.
Expenses With David
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'google_drive' | |
class Transaction | |
def initialize(date, merchant, amount) | |
@date = date | |
@merchant = merchant | |
@amount = amount | |
end | |
def self.all | |
ws.rows.map{|row| Transaction.new row[0], row[1], row[2]} | |
end | |
def self.sheet=(sheet) | |
@@sheet = sheet | |
end | |
end | |
# set you session | |
session = GoogleDrive.login("[email protected]", "mypassword") | |
# Open file | |
ws = session.spreadsheet_by_key("pz7XtlQC-PYx-jrVMJErTcg").worksheets[0] | |
# to read do... | |
date = ws[1,1] | |
merchant = ws[2,1] | |
# ... | |
# Yet another way to do so. | |
p ws.rows #==> [["fuga", ""], ["foo", "bar]] | |
Transaction.sheet = ws | |
ws.rows.each{|row| Transaction.new row[0], row[1], row[2]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment