Method: Multimethod::Parameter#score
- Defined in:
- lib/multimethod/parameter.rb
#score(arg) ⇒ Object
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.
189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/multimethod/parameter.rb', line 189 def score(arg) if @restarg score = RESTARG_SCORE elsif @default && ! arg score = DEFAULT_SCORE else score = all_types(arg).index(type_object) end # $stderr.puts " score(#{signature.to_s}, #{to_s}, #{arg && arg.name}) => #{score}" score end |