Class: Googletastic::Spreadsheet
- Inherits:
-
Base
- Object
- Hash
- Base
- Googletastic::Spreadsheet
show all
- Defined in:
- lib/googletastic/spreadsheet.rb
Constant Summary
Mixins::Namespaces::NAMESPACES
Instance Attribute Summary collapse
Attributes inherited from Base
#acl, #attachment_path, #created_at, #etag, #head, #id, #keep_raw, #raw, #response, #synced_with, #updated_at
#attributes
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #to_xml
included
included
included
included
#attribute_names, #has_attribute?, #inspect
included
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
3
4
5
|
# File 'lib/googletastic/spreadsheet.rb', line 3
def content
@content
end
|
#edit_id ⇒ Object
Returns the value of attribute edit_id.
3
4
5
|
# File 'lib/googletastic/spreadsheet.rb', line 3
def edit_id
@edit_id
end
|
#title ⇒ Object
Returns the value of attribute title.
3
4
5
|
# File 'lib/googletastic/spreadsheet.rb', line 3
def title
@title
end
|
Class Method Details
.client_class ⇒ Object
44
45
46
|
# File 'lib/googletastic/spreadsheet.rb', line 44
def client_class
"Spreadsheets"
end
|
.index_url ⇒ Object
48
49
50
|
# File 'lib/googletastic/spreadsheet.rb', line 48
def index_url
"http://spreadsheets.google.com/feeds/spreadsheets/private/full"
end
|
.show_url(id) ⇒ Object
52
53
54
|
# File 'lib/googletastic/spreadsheet.rb', line 52
def show_url(id)
"http://spreadsheets.google.com/feeds/spreadsheets/private/full/#{id}"
end
|
.unmarshall(xml) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/googletastic/spreadsheet.rb', line 60
def unmarshall(xml)
head = unmarshall_head(xml)
records = xml.xpath("//atom:entry", ns_tag("atom")).collect do |record|
etag = record["etag"].to_s
id = record.xpath("atom:id", ns_tag("atom")).first.text.gsub("http://spreadsheets.google.com/feeds/spreadsheets/", "")
edit_id = record.xpath("atom:link[@rel='alternate']", ns_tag("atom")).first
edit_id = edit_id["href"].gsub("http://spreadsheets.google.com/ccc?key=", "") if edit_id
title = record.xpath("atom:title", ns_tag("atom")).first.text
content = record.xpath("atom:content", ns_tag("atom")).first.text
created_at = record.xpath("atom:published", ns_tag("atom")).text
updated_at = record.xpath("atom:updated", ns_tag("atom")).text
Googletastic::Spreadsheet.new(
:id => id,
:etag => etag,
:edit_id => edit_id,
:title => title,
:content => content,
:updated_at => DateTime.parse(updated_at),
:head => head
)
end
records
end
|
.worksheet_url(id) ⇒ Object
56
57
58
|
# File 'lib/googletastic/spreadsheet.rb', line 56
def worksheet_url(id)
"http://spreadsheets.google.com/feeds/worksheets/#{id}/private/full"
end
|
Instance Method Details
#columns ⇒ Object
35
36
37
38
39
|
# File 'lib/googletastic/spreadsheet.rb', line 35
def columns
return @columns if @columns
row = @rows ? @rows.first : Googletastic::Row.first(:key => self.id, :worksheet_id => worksheet.id)
@columns = row.data.keys
end
|
31
32
33
|
# File 'lib/googletastic/spreadsheet.rb', line 31
def form
@form ||= Googletastic::Form.find(self.id)
end
|
#num_rows ⇒ Object
18
19
20
|
# File 'lib/googletastic/spreadsheet.rb', line 18
def num_rows
worksheet.num_rows
end
|
#rows ⇒ Object
27
28
29
|
# File 'lib/googletastic/spreadsheet.rb', line 27
def rows
@rows ||= Googletastic::Row.all(:key => self.id, :worksheet_id => worksheet.id)
end
|
#table ⇒ Object
13
14
15
|
# File 'lib/googletastic/spreadsheet.rb', line 13
def table
@table ||= Googletastic::Table.first(:key => self.id)
end
|
#total_rows ⇒ Object
23
24
25
|
# File 'lib/googletastic/spreadsheet.rb', line 23
def total_rows
@total_rows ||= Googletastic::Row.head(:key => self.id, :worksheet_id => worksheet.id).total_results
end
|
#worksheet ⇒ Object
9
10
11
|
# File 'lib/googletastic/spreadsheet.rb', line 9
def worksheet
@worksheet ||= Googletastic::Worksheet.first(:key => self.id)
end
|
#worksheet_url ⇒ Object
5
6
7
|
# File 'lib/googletastic/spreadsheet.rb', line 5
def worksheet_url
self.class.worksheet_url(self.id)
end
|