Class: Googletastic::Worksheet
- Defined in:
- lib/googletastic/worksheet.rb
Constant Summary
Constants included from Mixins::Namespaces
Mixins::Namespaces::NAMESPACES
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#num_columns ⇒ Object
Returns the value of attribute num_columns.
-
#num_rows ⇒ Object
Returns the value of attribute num_rows.
-
#spreadsheet_id ⇒ Object
Returns the value of attribute spreadsheet_id.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from Base
#acl, #attachment_path, #created_at, #etag, #head, #id, #keep_raw, #raw, #response, #synced_with, #updated_at
Attributes included from Mixins::Attributes
Class Method Summary collapse
- .build_url(options) ⇒ Object
- .client_class ⇒ Object
- .show_url(id) ⇒ Object
- .unmarshall(xml) ⇒ Object
Methods inherited from Base
Methods included from Mixins::Pagination
Methods included from Mixins::Finders
Methods included from Mixins::Parsing
Methods included from Mixins::Requesting
Methods included from Mixins::Attributes
#attribute_names, #has_attribute?, #inspect
Methods included from Mixins::Namespaces
Constructor Details
This class inherits a constructor from Googletastic::Base
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
3 4 5 |
# File 'lib/googletastic/worksheet.rb', line 3 def content @content end |
#num_columns ⇒ Object
Returns the value of attribute num_columns.
3 4 5 |
# File 'lib/googletastic/worksheet.rb', line 3 def num_columns @num_columns end |
#num_rows ⇒ Object
Returns the value of attribute num_rows.
3 4 5 |
# File 'lib/googletastic/worksheet.rb', line 3 def num_rows @num_rows end |
#spreadsheet_id ⇒ Object
Returns the value of attribute spreadsheet_id.
3 4 5 |
# File 'lib/googletastic/worksheet.rb', line 3 def spreadsheet_id @spreadsheet_id end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/googletastic/worksheet.rb', line 3 def title @title end |
Class Method Details
.build_url(options) ⇒ Object
16 17 18 19 20 |
# File 'lib/googletastic/worksheet.rb', line 16 def build_url() raise "You must specify an spreadsheet key 'key' for a worksheet" unless [:key] [:url] ||= show_url([:key]) super() end |
.client_class ⇒ Object
8 9 10 |
# File 'lib/googletastic/worksheet.rb', line 8 def client_class "Spreadsheets" end |
.show_url(id) ⇒ Object
12 13 14 |
# File 'lib/googletastic/worksheet.rb', line 12 def show_url(id) "http://spreadsheets.google.com/feeds/worksheets/#{id}/private/full" end |
.unmarshall(xml) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/googletastic/worksheet.rb', line 22 def unmarshall(xml) head = unmarshall_head(xml) records = xml.xpath("//atom:entry", ns_tag("atom")).collect do |record| id = record.xpath("atom:id", ns_tag("atom")).first.text ids = id =~ /http:\/\/spreadsheets\.google\.com\/feeds\/worksheets\/([^\/]+)\/([^\/]+)/ spreadsheet_id = $1 id = $2 title = record.xpath("atom:title", ns_tag("atom")).first.text content = record.xpath("atom:content", ns_tag("atom")).first.text updated_at = record.xpath("atom:updated", ns_tag("atom")).text num_rows = record.xpath("gs:rowCount", ns_tag("gs")).text.to_i num_columns = record.xpath("gs:colCount", ns_tag("gs")).text.to_i worksheet = Googletastic::Worksheet.new( :id => id, :spreadsheet_id => spreadsheet_id, :title => title, :content => content, :num_rows => num_rows, :num_columns => num_columns, :updated_at => DateTime.parse(updated_at), :head => head ) worksheet end records end |