Class: Dossier::Result::Formatted

Inherits:
Dossier::Result show all
Defined in:
lib/dossier/result.rb

Instance Attribute Summary

Attributes inherited from Dossier::Result

#adapter_results, #report

Instance Method Summary collapse

Methods inherited from Dossier::Result

#arrays, #body, #footers, #hashes, #initialize, #raw_headers, #row_hash, #rows

Constructor Details

This class inherits a constructor from Dossier::Result

Instance Method Details

#eachObject



62
63
64
# File 'lib/dossier/result.rb', line 62

def each
  adapter_results.rows.each { |row| yield format(row) }
end

#format(row) ⇒ Object



66
67
68
69
70
71
72
73
74
75
# File 'lib/dossier/result.rb', line 66

def format(row)
  unless row.kind_of?(Enumerable)
    raise ArgumentError.new("#{row.inspect} must be a kind of Enumerable") 
  end
  
  displayable_columns(row).map { |value, i|
    column = raw_headers.at(i)
    apply_formatter(row, column, value)
  }
end

#headersObject



54
55
56
57
58
59
60
# File 'lib/dossier/result.rb', line 54

def headers
  @formatted_headers ||= raw_headers.select { |h|
    report.display_column?(h)
  }.map { |h|
    report.format_header(h)
  }
end