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.
449 450 451 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 449 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.
458 459 460 461 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 458 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.
463 464 465 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 463 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.
467 468 469 470 471 472 473 474 475 476 477 478 479 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 467 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.
453 454 455 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 453 def to @expected.to || Float::INFINITY end |