Class: Dossier::Result
- Inherits:
-
Object
show all
- Includes:
- Enumerable
- Defined in:
- lib/dossier/result.rb
Defined Under Namespace
Classes: Formatted, Unformatted
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(adapter_results, report) ⇒ Result
Returns a new instance of Result.
7
8
9
10
|
# File 'lib/dossier/result.rb', line 7
def initialize(adapter_results, report)
self.adapter_results = adapter_results
self.report = report
end
|
Instance Attribute Details
#adapter_results ⇒ Object
Returns the value of attribute adapter_results.
5
6
7
|
# File 'lib/dossier/result.rb', line 5
def adapter_results
@adapter_results
end
|
#report ⇒ Object
Returns the value of attribute report.
5
6
7
|
# File 'lib/dossier/result.rb', line 5
def report
@report
end
|
Instance Method Details
#arrays ⇒ Object
33
34
35
|
# File 'lib/dossier/result.rb', line 33
def arrays
@arrays ||= [] + rows
end
|
#body ⇒ Object
20
21
22
23
|
# File 'lib/dossier/result.rb', line 20
def body
size = rows.length - report.options[:footer].to_i
@body ||= size < 0 ? [] : rows.first(size)
end
|
#each ⇒ Object
48
49
50
|
# File 'lib/dossier/result.rb', line 48
def each
raise NotImplementedError.new("#{self.class.name} must define `each`")
end
|
25
26
27
|
# File 'lib/dossier/result.rb', line 25
def
@footer ||= rows.last(report.options[:footer].to_i)
end
|
#hashes ⇒ Object
37
38
39
40
|
# File 'lib/dossier/result.rb', line 37
def hashes
return @hashes if defined?(@hashes)
@hashes = rows.map { |row| row_hash(row) }
end
|
16
17
18
|
# File 'lib/dossier/result.rb', line 16
def
raise NotImplementedError.new("#{self.class.name} must implement `headers', use `raw_headers' for adapter headers")
end
|
12
13
14
|
# File 'lib/dossier/result.rb', line 12
def
@raw_headers ||= adapter_results.
end
|
#row_hash(row) ⇒ Object
this is the method that creates the individual hash entry hashes should always use raw headers
44
45
46
|
# File 'lib/dossier/result.rb', line 44
def row_hash(row)
Hash[.zip(row)].with_indifferent_access
end
|
#rows ⇒ Object
29
30
31
|
# File 'lib/dossier/result.rb', line 29
def rows
@rows ||= to_a
end
|