Class: Attractor::ConsoleReporter

Inherits:
BaseReporter show all
Defined in:
lib/attractor/reporters/console_reporter.rb

Overview

console reporter

Defined Under Namespace

Classes: CSVFormatter, JSONFormatter, TableFormatter

Instance Attribute Summary

Attributes inherited from BaseReporter

#file_prefix, #types, #values

Instance Method Summary collapse

Methods inherited from BaseReporter

#render, #suggestions

Constructor Details

#initialize(format:, **other) ⇒ ConsoleReporter

Returns a new instance of ConsoleReporter.



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/attractor/reporters/console_reporter.rb', line 79

def initialize(format:, **other)
  super(**other)
  @formatter = case format.to_sym
  when :csv
    CSVFormatter.new
  when :json
    JSONFormatter.new
  else
    TableFormatter.new
  end
end

Instance Method Details

#reportObject



91
92
93
94
# File 'lib/attractor/reporters/console_reporter.rb', line 91

def report
  super
  @formatter.call(@calculators)
end