Class: Dossier::Result::Formatted
- Inherits:
-
Dossier::Result
- Object
- Dossier::Result
- Dossier::Result::Formatted
- Defined in:
- lib/dossier/result.rb
Instance Attribute Summary
Attributes inherited from Dossier::Result
Instance Method Summary collapse
Methods inherited from Dossier::Result
#arrays, #body, #footers, #hashes, #headers, #initialize, #row_hash, #rows
Constructor Details
This class inherits a constructor from Dossier::Result
Instance Method Details
#each ⇒ Object
46 47 48 49 50 |
# File 'lib/dossier/result.rb', line 46 def each adapter_results.rows.each do |row| yield format(row) end end |
#format(row) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/dossier/result.rb', line 52 def format(row) unless row.kind_of?(Enumerable) raise ArgumentError.new("#{row.inspect} must be a kind of Enumerable") end row.each_with_index.map do |field, i| method_name = "format_#{headers[i]}" if report.respond_to?(method_name) # Provide the row as context if the formatter takes two arguments if report.method(method_name).arity == 2 report.public_send(method_name, field, row_hash(row)) else report.public_send(method_name, field) end else field end end end |