class Puppet::Pops::Types::SizeMismatch
@api private
Public Instance Methods
from()
click to toggle source
# File lib/puppet/pops/types/type_mismatch_describer.rb 450 def from 451 @expected.from || 0 452 end
merge(path, o)
click to toggle source
@return A new instance with the least restrictive respective boundaries
# File lib/puppet/pops/types/type_mismatch_describer.rb 459 def merge(path, o) 460 range = PIntegerType.new(from < o.from ? from : o.from, to > o.to ? to : o.to) 461 self.class.new(path, range, @actual) 462 end
message(variant, position)
click to toggle source
# File lib/puppet/pops/types/type_mismatch_describer.rb 464 def message(variant, position) 465 "#{variant}#{position} expects size to be #{range_to_s(expected, '0')}, got #{range_to_s(actual, '0')}" 466 end
range_to_s(range, zero_string)
click to toggle source
# File lib/puppet/pops/types/type_mismatch_describer.rb 468 def range_to_s(range, zero_string) 469 min = range.from || 0 470 max = range.to || Float::INFINITY 471 if min == max 472 min == 0 ? zero_string : min.to_s 473 elsif min == 0 474 max == Float::INFINITY ? 'unlimited' : "at most #{max}" 475 elsif max == Float::INFINITY 476 "at least #{min}" 477 else 478 "between #{min} and #{max}" 479 end 480 end
to()
click to toggle source
# File lib/puppet/pops/types/type_mismatch_describer.rb 454 def to 455 @expected.to || Float::INFINITY 456 end