Class: Google
Constant Summary
collapse
- TIMEOUT_IN_SECONDS =
2
Instance Method Summary
collapse
Methods inherited from Openoffice
#as_letter, #first_column, #first_column_as_letter, #first_row_as_letter, #formula, #formula?, #last_column, #last_column_as_letter, #last_row_as_letter, letter_to_number, #number_to_letter, #officeversion, #reload, #row, #save, #set, #to_s
Constructor Details
#initialize(user, password, spreadsheetkey) ⇒ Google
Returns a new instance of Google.
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/roo/google.rb', line 92
def initialize(user, password, spreadsheetkey)
@cells_read = false
@cell = Hash.new
@cell_type = Hash.new
Timeout.timeout(TIMEOUT_IN_SECONDS) {
@gs = GoogleSpreadSheet.new(spreadsheetkey)
@gs.authenticate(user, password)
@default_sheet = nil
}
end
|
Instance Method Details
#cell(row, col) ⇒ Object
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/roo/google.rb', line 116
def cell(row, col)
row,col = normalize(row,col)
cellname = number_to_letter(col)+row.to_s
Timeout.timeout(TIMEOUT_IN_SECONDS) {
return @gs.evaluate_cell(cellname) }
end
|
#celltype(row, col) ⇒ Object
129
130
131
|
# File 'lib/roo/google.rb', line 129
def celltype(row, col)
"string"
end
|
#default_sheet=(numberofsheet) ⇒ Object
112
113
114
|
# File 'lib/roo/google.rb', line 112
def default_sheet=(numberofsheet)
@gs.default_sheet = numberofsheet
end
|
#empty?(row, col) ⇒ Boolean
133
134
135
|
# File 'lib/roo/google.rb', line 133
def empty?(row, col)
cell(row, col).empty?
end
|
#first_row ⇒ Object
172
173
174
175
|
# File 'lib/roo/google.rb', line 172
def first_row
read_cells unless @cells_read
1
end
|
#last_row ⇒ Object
177
178
179
180
|
# File 'lib/roo/google.rb', line 177
def last_row
read_cells unless @cells_read
100
end
|
#read_cells ⇒ Object
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# File 'lib/roo/google.rb', line 137
def read_cells
file = File.new("/home/tp/aaa.xml")
@doc = REXML::Document.new file
file.close
@doc.each_element do |element|
if element.name == "feed"
p "feed gefunden"
element.each_element do |feed|
p feed
feed.each_element do |fe|
p fe.name
end
end
end
end
1.upto(10) do |y|
Openoffice.letter_to_number('A').upto(Openoffice.letter_to_number('H')) do |x|
end
end
@cells_read = true
end
|
#sheets ⇒ Object
103
104
105
106
107
108
109
110
|
# File 'lib/roo/google.rb', line 103
def sheets
if DateTime.now < Date.new(2007,6,15)
return ["Sheet eins","Sheet zwei","Sheet drei"]
else
return []
end
end
|