Module: Puppet::Pops::Evaluator::CallableMismatchDescriber Private

Defined in:
lib/puppet/pops/evaluator/callable_mismatch_describer.rb

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

Class Method Summary collapse

Class Method Details

.diff_string(name, args_type, supported_signatures) ⇒ 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.

Produces a string with the difference between the given arguments and support signature(s).



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puppet/pops/evaluator/callable_mismatch_describer.rb', line 10

def self.diff_string(name, args_type, supported_signatures)
  result = [ ]
  if supported_signatures.size == 1
    signature = supported_signatures[0]
    params_type  = signature.type.param_types
    block_type   = signature.type.block_type
    params_names = signature.parameter_names
    result << "expected:\n  #{name}(#{signature_string(signature)}) - #{arg_count_string(signature.type)}"
  else
    result << "expected one of:\n"
    result << supported_signatures.map do |signature|
      params_type = signature.type.param_types
      "  #{name}(#{signature_string(signature)}) - #{arg_count_string(signature.type)}"
    end.join("\n")
  end

  result << "\nactual:\n  #{name}(#{arg_types_string(args_type)}) - #{arg_count_string(args_type)}"

  result.join('')
end