Class: Roo::Base
Instance Attribute Summary collapse
-
#partial_match ⇒ Object
changes: - added option :partial_match to allow to use headers that only partially match the query - added option :required_headers to force the result to have at least these columns - allow option :headers to contain an array with header labels that will be forced when no header row is found - improved proper range scanning (first_row->last_row and first_column->last_column).
Instance Method Summary collapse
Instance Attribute Details
#partial_match ⇒ Object
changes:
-
added option :partial_match to allow to use headers that only partially match the query
-
added option :required_headers to force the result to have at least these columns
-
allow option :headers to contain an array with header labels that will be forced when no header row is found
-
improved proper range scanning (first_row->last_row and first_column->last_column)
16 17 18 |
# File 'lib/libis/tools/extend/roo.rb', line 16 def partial_match @partial_match end |
Instance Method Details
#each(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/libis/tools/extend/roo.rb', line 18 def each( = {}) return to_enum(:each, ) unless block_given? @partial_match = .delete(:partial_match) if .has_key?(:partial_match) required_headers = .delete(:required_headers) if .has_key?(:required_headers) if .empty? first_row.upto(last_row) do |line| yield row(line) end else clean_sheet_if_need() @headers = search_or_set_header() if required_headers raise Roo::HeaderRowIncompleteError unless headers.keys & required_headers == required_headers end header_line.upto(last_row) do |line| yield(headers.each_with_object({}) { |(k, v), hash| hash[k] = cell(line, v) }) end end end |