Module: QAT::Reporter::Times::Report

Extended by:
Helpers::TimeFormat
Includes:
Logger
Defined in:
lib/qat/reporter/times/report.rb

Overview

Namespace for Times Report outputs

Class Method Summary collapse

Methods included from Helpers::TimeFormat

human_formatted_time

Class Method Details

.table(data) ⇒ String

Builds an ascii table time report for console output

Returns:

  • (String)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/qat/reporter/times/report.rb', line 15

def self.table(data)
  if data.any?
    table_data = data.map do |_, measure|
      {
        'Interaction' => measure[:name],
        'Start'       => measure[:start].strftime('%Y-%m-%d %H:%M:%S %z'),
        'End'         => measure[:end].strftime('%Y-%m-%d %H:%M:%S %z'),
        'Duration'    => human_formatted_time(measure[:duration]),
      }
    end

    QAT::Reporter::Helpers::AsciiTable.new(table_data).to_s
  else
    "No time measure was recorded!"
  end
end