Class: Puppet::Pops::Types::SizeMismatch Private
- Inherits:
-
ExpectedActualMismatch
- Object
- Mismatch
- ExpectedActualMismatch
- Puppet::Pops::Types::SizeMismatch
- 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.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from ExpectedActualMismatch
Attributes inherited from Mismatch
Instance Method Summary collapse
- #from ⇒ Object private
-
#merge(path, o) ⇒ Object
private
A new instance with the least restrictive respective boundaries.
- #message(variant, position) ⇒ Object private
- #range_to_s(range, zero_string) ⇒ Object private
- #to ⇒ Object private
Methods inherited from ExpectedActualMismatch
Methods inherited from Mismatch
#==, #canonical_path, #chop_path, #eql?, #format, #hash, #initialize, #path_string, #to_s
Constructor Details
This class inherits a constructor from Puppet::Pops::Types::ExpectedActualMismatch
Instance Method Details
#from ⇒ 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.
439 440 441 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 439 def from @expected.from || 0 end |
#merge(path, o) ⇒ 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.
Returns A new instance with the least restrictive respective boundaries.
448 449 450 451 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 448 def merge(path, o) range = PIntegerType.new(from < o.from ? from : o.from, to > o.to ? to : o.to) self.class.new(path, range, @actual) end |
#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.
453 454 455 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 453 def (variant, position) "#{variant}#{position} expects size to be #{range_to_s(expected, '0')}, got #{range_to_s(actual, '0')}" end |
#range_to_s(range, zero_string) ⇒ 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.
457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 457 def range_to_s(range, zero_string) min = range.from || 0 max = range.to || Float::INFINITY if min == max min == 0 ? zero_string : min.to_s elsif min == 0 max == Float::INFINITY ? 'unlimited' : "at most #{max}" elsif max == Float::INFINITY "at least #{min}" else "between #{min} and #{max}" end end |
#to ⇒ 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.
443 444 445 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 443 def to @expected.to || Float::INFINITY end |