Method: Roo::Base#each
- Defined in:
- lib/roo/base.rb
#each(options = {}) ⇒ Object
you can also pass in a :clean => true option to strip the sheet of control characters and white spaces around columns
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/roo/base.rb', line 282 def each( = {}) return to_enum(:each, ) unless block_given? if .empty? 1.upto(last_row) do |line| yield row(line) end else clean_sheet_if_need() search_or_set_header() headers = @headers || (first_column..last_column).each_with_object({}) do |col, hash| hash[cell(@header_line, col)] = col end @header_line.upto(last_row) do |line| yield(headers.each_with_object({}) { |(k, v), hash| hash[k] = cell(line, v) }) end end end |