Class: Demos::Spreadsheet::CSV
Instance Attribute Summary
#node, #provides, #publisher
Instance Method Summary
collapse
#children, #children?, compile, computed, computed!, #draw, #draw_with, #dump, #emit, #initialize, inject, inject!, #method_missing, mount, #on_resize, provide, provides, #render, style, styles_get, template, template_from_file, template_get, #update, use, uses
Constructor Details
This class inherits a constructor from Hokusai::Block
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Hokusai::Block
Instance Method Details
#change_cell(rowi, celli) ⇒ Object
188
189
190
|
# File 'ui/examples/spreadsheet/csv.rb', line 188
def change_cell(rowi, celli)
emit("modified")
end
|
#column_count ⇒ Object
233
234
235
|
# File 'ui/examples/spreadsheet/csv.rb', line 233
def column_count
csv.to_a.map(&:size).max
end
|
#empty_row ⇒ Object
229
230
231
|
# File 'ui/examples/spreadsheet/csv.rb', line 229
def empty_row
Array.new(.size - 1, nil)
end
|
196
197
198
199
200
201
202
203
204
205
206
207
|
# File 'ui/examples/spreadsheet/csv.rb', line 196
def formula(row_index, target, pos1, pos2)
memo = 0
srow, scol = pos1.split(":")
erow, ecol = pos2.split(":")
(srow.to_i..erow.to_i).each do |idx|
memo += csv[idx][scol.to_i].to_i
end
csv[row_index + 1][target] = memo
end
|
192
193
194
|
# File 'ui/examples/spreadsheet/csv.rb', line 192
def (index)
[index] || ""
end
|
241
242
243
|
# File 'ui/examples/spreadsheet/csv.rb', line 241
def
csv.to_a[0]
end
|
#row_count ⇒ Object
237
238
239
|
# File 'ui/examples/spreadsheet/csv.rb', line 237
def row_count
csv.to_a.size
end
|
251
252
253
|
# File 'ui/examples/spreadsheet/csv.rb', line 251
def (index)
"header-#{index}"
end
|
#row_key(index) ⇒ Object
255
256
257
|
# File 'ui/examples/spreadsheet/csv.rb', line 255
def row_key(index)
"row-#{index}"
end
|
#rows ⇒ Object
219
220
221
222
223
224
225
226
227
|
# File 'ui/examples/spreadsheet/csv.rb', line 219
def rows
(1..row_count).map do |rindex|
row = csv[rindex] || Array.new(column_count, nil)
(0..column_count).map do |cindex|
row[cindex] || ""
end
end
end
|
#update_cell(row_index, cell_index, value) ⇒ Object
209
210
211
212
213
214
215
216
217
|
# File 'ui/examples/spreadsheet/csv.rb', line 209
def update_cell(row_index, cell_index, value)
if csv[row_index + 1].nil?
csv[row_index + 1] = empty_row
end
csv[row_index + 1][cell_index] = value
emit("update", csv)
end
|