Class: GoogleDrive::Table
- Inherits:
-
Object
- Object
- GoogleDrive::Table
- Includes:
- Util
- Defined in:
- lib/google_drive/table.rb
Overview
DEPRECATED: Table and Record feeds are deprecated and they will not be available after March 2012.
Use GoogleDrive::Worksheet#add_table to create table. Use GoogleDrive::Worksheet#tables to get GoogleDrive::Table objects.
Constant Summary
Constants included from Util
Util::DOCS_BASE_URL, Util::EXT_TO_CONTENT_TYPE
Instance Attribute Summary collapse
-
#worksheet_title ⇒ Object
readonly
Title of the worksheet the table belongs to.
Instance Method Summary collapse
-
#add_record(values) ⇒ Object
Adds a record.
-
#delete ⇒ Object
Deletes this table.
-
#initialize(session, entry) ⇒ Table
constructor
:nodoc:.
-
#records ⇒ Object
Returns records in the table.
Methods included from Util
concat_url, encode_query, h, to_v3_url
Constructor Details
#initialize(session, entry) ⇒ Table
:nodoc:
20 21 22 23 24 25 26 |
# File 'lib/google_drive/table.rb', line 20 def initialize(session, entry) #:nodoc: @columns = {} @worksheet_title = entry.css("gs|worksheet")[0]["name"] @records_url = entry.css("content")[0]["src"] @edit_url = entry.css("link[rel='edit']")[0]["href"] @session = session end |
Instance Attribute Details
#worksheet_title ⇒ Object (readonly)
Title of the worksheet the table belongs to.
29 30 31 |
# File 'lib/google_drive/table.rb', line 29 def worksheet_title @worksheet_title end |
Instance Method Details
#add_record(values) ⇒ Object
Adds a record.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/google_drive/table.rb', line 32 def add_record(values) fields = "" values.each() do |name, value| fields += "<gs:field name='#{h(name)}'>#{h(value)}</gs:field>" end xml =<<-EOS <entry xmlns="http://www.w3.org/2005/Atom" xmlns:gs="http://schemas.google.com/spreadsheets/2006"> #{fields} </entry> EOS @session.request(:post, @records_url, :data => xml) end |
#delete ⇒ Object
Deletes this table. Deletion takes effect right away without calling save().
54 55 56 |
# File 'lib/google_drive/table.rb', line 54 def delete @session.request(:delete, @edit_url, :header => {"If-Match" => "*"}) end |