Class: AreWeThereYet::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/are_we_there_yet/formatter.rb

Class Method Summary collapse

Class Method Details

.format_for_output(data) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/are_we_there_yet/formatter.rb', line 3

def self.format_for_output(data)
  if data.first.has_key? :file
    headers = %Q{"File Path","Average Execution Time"\n\n}
    data.inject(headers) do |output_string, metric_record|
      output_string += %Q{"#{metric_record[:file]}",#{metric_record[:average_execution_time]}\n}
    end
  else
    headers = %Q{"Example","Average Execution Time"\n\n}
    data.inject(headers) do |output_string, metric_record|
      output_string += %Q{"#{metric_record[:example]}",#{metric_record[:average_execution_time]}\n}
    end
  end
end