Class: Tablespoon::Doc

Inherits:
Object
  • Object
show all
Defined in:
lib/tablespoon.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, opts = {}) ⇒ Doc

Returns a new instance of Doc.



11
12
13
14
15
16
17
18
# File 'lib/tablespoon.rb', line 11

def initialize( key, opts = {} )
  if opts[:username] && opts [:password]
    @session = GoogleDrive.( opts[:username], opts[:password] )
    @doc   = session.spreadsheet_by_key( key )
  else
    raise "No username and password" 
  end
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



9
10
11
# File 'lib/tablespoon.rb', line 9

def doc
  @doc
end

#sessionObject (readonly)

Returns the value of attribute session.



9
10
11
# File 'lib/tablespoon.rb', line 9

def session
  @session
end

Instance Method Details

#get_table(x, opts = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/tablespoon.rb', line 20

def get_table( x, opts = {} )

  if x.class == String
    return Table.new @doc.worksheet_by_title( x ), opts
  else
    return Table.new @doc.worksheets[x], opts
  end
  
end