Class Multimethod::Parameter
In: lib/multimethod/parameter.rb
Parent: Object

Represents a Parameter in a Signature.

A Parameter has a name, type and position.

Parameters may also have a default value or may be a restarg, a parameter that collects all remaining arguments.

Restarg parameters have a lower score than other arguments.

Unlike Ruby parameters, Parameters are typed. Unspecified Parameter types default to Kernel.

Methods

<=>   all_types   debug=   name=   new   scan_string   score   to_ruby_arg   to_s   to_s_name   type_object  

Included Modules

Comparable

Constants

DEFAULT_SCORE_BASE = 200   The score base used for all Parameters with defaults.
DEFAULT_SCORE = DEFAULT_SCORE_BASE + 100   The score used for all Parameters with defaults and no argument.
RESTARG_SCORE = DEFAULT_SCORE + 100   The score used for all restarg Parameters.

Attributes

default  [RW]  The Parameter’s default value expression.
i  [RW]  The Parameter’s offset in the Signature’s parameter list. Parameter 0 is the implied "self" Parameter.
name  [RW]  The Parameter name.
restarg  [RW]  True if the Parameter is a restarg: e.g.: "*args"
signature  [RW]  The Parameter’s owning Signature.
type  [RW]  The Paremeter’s type, defaults to Kernel.
verbose  [RW]  Defines level of verbosity during processing.

Public Class methods

Public Instance methods

Compare two Parameters. Parameter name is insignificant.

Returns a list of all parent Modules of an argument type, including itself, in most-specialized to least-specialized order.

Scan a string for a Parameter specification.

Returns the score of this Parameter matching an argument type.

The score is determined by the relative distance of the Parameter to the argument type. A lower distance means a tighter match of this Parameter.

If arg is nil, this Parameter is being matched as a restarg or a parameter default.

Parameters with restargs or unspecfied default arguments score lower, see RESTARG_SCORE, DEFAULT_SCORE.

Return a String representing this Parameter as a Ruby method parameter.

Returns a String representing this Parameter in a Signature string.

Return a String representing this Parameter’s name. Restargs will be prefixed with ’*’.

Resolves type name

[Validate]