Class: Puppet::Pops::Types::CountMismatch Private

Inherits:
SizeMismatch show all
Defined in:
lib/puppet/pops/types/type_mismatch_describer.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from ExpectedActualMismatch

#actual, #expected

Attributes inherited from Mismatch

#path

Instance Method Summary collapse

Methods inherited from SizeMismatch

#from, #merge, #range_to_s, #to

Methods inherited from ExpectedActualMismatch

#==, #hash

Methods inherited from Mismatch

#==, #canonical_path, #chop_path, #eql?, #format, #hash, #merge, #path_string, #to_s

Constructor Details

#initialize(path, expected, actual) ⇒ CountMismatch

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CountMismatch.



474
475
476
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 474

def initialize(path, expected, actual)
  super(path, expected, actual)
end

Instance Method Details

#message(variant, position) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



478
479
480
481
482
483
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 478

def message(variant, position)
  min = expected.from || 0
  max = expected.to || Float::INFINITY
  suffix = min == 1 && (max == 1 || max == Float::INFINITY) || min == 0 && max == 1 ? '' : 's'
  "#{variant}#{position} expects #{range_to_s(expected, 'no')} argument#{suffix}, got #{range_to_s(actual, 'none')}"
end