Class: SimpleCov::Formatter::MultiFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov-multi/version.rb,
lib/simplecov-multi.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMultiFormatter

Returns a new instance of MultiFormatter.



6
7
8
# File 'lib/simplecov-multi.rb', line 6

def initialize
  @formatters = []
end

Instance Attribute Details

#formattersObject (readonly)

Returns the value of attribute formatters.



4
5
6
# File 'lib/simplecov-multi.rb', line 4

def formatters
  @formatters
end

Instance Method Details

#<<(formatter) ⇒ Object

Append a new formatter



19
20
21
22
23
24
# File 'lib/simplecov-multi.rb', line 19

def <<(formatter)
  unless formatter.respond_to?(:format)
    raise 'Formatter does not respond to `format` method'
  end
  @formatters << formatter
end

#format(result) ⇒ Object

Iterate through supplied formatters calling their format methods and supplying the given result



12
13
14
15
16
# File 'lib/simplecov-multi.rb', line 12

def format(result)
  @formatters.each do |formatter|
    formatter.format(result)
  end
end