Class: Puppet::Pops::Types::TypeMismatch Private
- Inherits:
-
ExpectedActualMismatch
- Object
- Mismatch
- ExpectedActualMismatch
- Puppet::Pops::Types::TypeMismatch
- Includes:
- LabelProvider
- 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
Constant Summary
Constants included from LabelProvider
LabelProvider::A, LabelProvider::AN, LabelProvider::SKIPPED_CHARACTERS, LabelProvider::VOWELS
Instance Attribute Summary
Attributes inherited from ExpectedActualMismatch
Attributes inherited from Mismatch
Instance Method Summary collapse
- #label(o) ⇒ Object private
-
#merge(path, o) ⇒ Object
private
A new instance with the least restrictive respective boundaries.
- #message(variant, position) ⇒ Object private
Methods included from LabelProvider
#a_an, #a_an_uc, #article, #combine_strings, #plural_s, #the, #the_uc
Methods inherited from ExpectedActualMismatch
#==, #hash, #initialize, #set_optional, #swap_expected
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
#label(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.
375 376 377 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 375 def label(o) o.to_s 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.
323 324 325 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 323 def merge(path, o) self.class.new(path, [expected, o.expected].flatten.uniq, 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.
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 327 def (variant, position) e = expected a = actual multi = false if @optional if e.is_a?(PVariantType) e = [PUndefType::DEFAULT] + e.types else e = [PUndefType::DEFAULT, e] end elsif e.is_a?(PVariantType) e = e.types end if e.is_a?(Array) if report_detailed?(e, a) a = detailed_actual_to_s(e, a) e = e.map { |t| t. } else e = e.map { |t| t.simple_name }.uniq a = a.simple_name end case e.size when 1 e = e[0] when 2 e = "#{e[0]} or #{e[1]}" multi = true else e = "#{e[0..e.size-2].join(', ')}, or #{e[e.size-1]}" multi = true end else if report_detailed?(e, a) a = detailed_actual_to_s(e, a) e = e. else e = e.simple_name a = a.simple_name end end if multi "#{variant}#{position} expects a value of type #{e}, got #{label(a)}" else "#{variant}#{position} expects #{a_an(e)} value, got #{label(a)}" end end |