Class: Dossier::Result::Formatted
Instance Attribute Summary
#adapter_results, #report
Instance Method Summary
collapse
#arrays, #body, #footers, #hashes, #initialize, #row_hash, #rows
Instance Method Details
#each ⇒ Object
53
54
55
|
# File 'lib/dossier/result.rb', line 53
def each
adapter_results.rows.each { |row| yield format(row) }
end
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/dossier/result.rb', line 57
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 |value, i|
column = .at(i)
method = "format_#{column}"
if report.respond_to?(method)
args = [method, value]
args << row_hash(row) if report.method(method).arity == 2
report.public_send(*args)
else
report.format_column(column, value)
end
end
end
|
49
50
51
|
# File 'lib/dossier/result.rb', line 49
def
@formatted_headers ||= super.map { |h| report.(h) }
end
|
47
|
# File 'lib/dossier/result.rb', line 47
alias :raw_headers :headers
|