Class: GoogleSpreadsheet::Table
- Inherits:
-
Object
- Object
- GoogleSpreadsheet::Table
- Includes:
- Util
- Defined in:
- lib/google_spreadsheet.rb
Overview
Use GoogleSpreadsheet::Worksheet#add_table to create table. Use GoogleSpreadsheet::Worksheet#tables to get GoogleSpreadsheet::Table objects.
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.
-
#initialize(session, entry) ⇒ Table
constructor
:nodoc:.
-
#records ⇒ Object
Returns records in the table.
Methods included from Util
as_utf8, encode_query, h, http_request, uri_encode
Constructor Details
#initialize(session, entry) ⇒ Table
:nodoc:
346 347 348 349 350 351 |
# File 'lib/google_spreadsheet.rb', line 346 def initialize(session, entry) #:nodoc: @columns = {} @worksheet_title = as_utf8(entry.search("gs:worksheet")[0]["name"]) @records_url = as_utf8(entry.search("content")[0]["src"]) @session = session end |
Instance Attribute Details
#worksheet_title ⇒ Object (readonly)
Title of the worksheet the table belongs to.
354 355 356 |
# File 'lib/google_spreadsheet.rb', line 354 def worksheet_title @worksheet_title end |
Instance Method Details
#add_record(values) ⇒ Object
Adds a record.
357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/google_spreadsheet.rb', line 357 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.post(@records_url, xml) end |