Class: GData::Spreadsheet
- Inherits:
-
Base
- Object
- Base
- GData::Spreadsheet
show all
- Defined in:
- lib/gdata/spreadsheet.rb
Instance Attribute Summary
Attributes inherited from Base
#service, #source, #url
Instance Method Summary
collapse
Methods inherited from Base
#authenticate, #get, #http, #post, #put, #request
Constructor Details
#initialize(spreadsheet_id) ⇒ Spreadsheet
Returns a new instance of Spreadsheet.
7
8
9
10
|
# File 'lib/gdata/spreadsheet.rb', line 7
def initialize(spreadsheet_id)
@spreadsheet_id = spreadsheet_id
super 'wise', 'gdata-ruby', 'spreadsheets.google.com'
end
|
Instance Method Details
#add_to_cell(formula) ⇒ Object
33
34
35
|
# File 'lib/gdata/spreadsheet.rb', line 33
def add_to_cell(formula)
save_entry(entry(formula))
end
|
#entry(formula, row = 1, col = 1) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/gdata/spreadsheet.rb', line 25
def entry(formula, row=1, col=1)
<<XML
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gs='http://schemas.google.com/spreadsheets/2006'>
<gs:cell row='#{row}' col='#{col}' inputValue='=#{formula}' />
</entry>
XML
end
|
#evaluate_cell(cell) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/gdata/spreadsheet.rb', line 12
def evaluate_cell(cell)
path = "/feeds/cells/#{@spreadsheet_id}/1/#{@headers ? "private" : "public"}/basic/#{cell}"
doc = Hpricot(request(path))
result = (doc/"content[@type='text']").inner_html
end
|
#save_entry(entry) ⇒ Object
19
20
21
22
23
|
# File 'lib/gdata/spreadsheet.rb', line 19
def save_entry(entry)
path = "/feeds/cells/#{@spreadsheet_id}/1/#{@headers ? 'private' : 'public'}/full"
post(path, entry)
end
|