Class: SimpleCov::Formatter::MultiFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/formatter/multi_formatter.rb,
sig/simplecov.rbs

Overview

Wraps multiple formatters so one configured formatter can drive several output formats (HTML + JSON, etc.) in a single run.

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.new(formatters = nil) ⇒ Class

Returns a newly built Class (not a MultiFormatter instance) whose instances respond to #format and #formatters. The argument is normalized with Array(): a single formatter, an array of formatters, or nil are all accepted.

Parameters:

  • formatters (Object) (defaults to: nil)

Returns:

  • (Class)


1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
# File 'sig/simplecov.rbs', line 1309

def self.new(formatters = nil)
  # Normalize eagerly and capture the list in the closure. Array()
  # is pure for every accepted input shape (nil, single formatter,
  # array, or another MultiFormatter class), so this is equivalent
  # to the historical lazy per-instance memoization.
  formatter_list = Array(formatters)
  Class.new do
    define_method :formatters do
      formatter_list
    end
    include InstanceMethods
  end
end