class Dossier::Result

Attributes

adapter_results[RW]
report[RW]

Public Class Methods

new(adapter_results, report) click to toggle source
# File lib/dossier/result.rb, line 7
def initialize(adapter_results, report)
  self.adapter_results = adapter_results
  self.report          = report
end

Public Instance Methods

arrays() click to toggle source
# File lib/dossier/result.rb, line 33
def arrays
  @arrays ||= [headers] + rows
end
body() click to toggle source
# 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() click to toggle source
# File lib/dossier/result.rb, line 48
def each
  raise NotImplementedError.new("#{self.class.name} must define `each`")
end
footers() click to toggle source
# File lib/dossier/result.rb, line 25
def footers
  @footer ||= rows.last(report.options[:footer].to_i)
end
hashes() click to toggle source
# File lib/dossier/result.rb, line 37
def hashes
  return @hashes if defined?(@hashes)
  @hashes = rows.map { |row| row_hash(row) }
end
headers() click to toggle source
# File lib/dossier/result.rb, line 16
def headers
  raise NotImplementedError.new("#{self.class.name} must implement `headers', use `raw_headers' for adapter headers")
end
raw_headers() click to toggle source
# File lib/dossier/result.rb, line 12
def raw_headers
  @raw_headers ||= adapter_results.headers
end
row_hash(row) click to toggle source

this is the method that creates the individual hash entry hashes should always use raw headers

# File lib/dossier/result.rb, line 44
def row_hash(row)
  Hash[raw_headers.zip(row)].with_indifferent_access
end
rows() click to toggle source
# File lib/dossier/result.rb, line 29
def rows
  @rows ||= to_a
end