Class: Test::Unit::Assertions::AssertionMessage::MaybeContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/test/unit/assertions.rb,
lib/test/unit/assertions.rb,
lib/test/unit/assertions.rb,
lib/test/unit/assertions.rb,
lib/test/unit/assertions.rb,
lib/test/unit/assertions.rb,
lib/test/unit/assertions.rb

Instance Method Summary collapse

Constructor Details

#initialize(value, &formatter) ⇒ MaybeContainer

Returns a new instance of MaybeContainer



2007
2008
2009
2010
# File 'lib/test/unit/assertions.rb', line 2007

def initialize(value, &formatter)
  @value = value
  @formatter = formatter
end

Instance Method Details

#inspectObject



2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
# File 'lib/test/unit/assertions.rb', line 2012

def inspect
  if @value.is_a?(Array)
    values = @value.collect do |value|
      @formatter.call(AssertionMessage.convert(value))
    end
    "[#{values.join(', ')}]"
  else
    @formatter.call(AssertionMessage.convert(@value))
  end
end