Exception: Dreck::AbsorptionError

Inherits:
DreckError
  • Object
show all
Defined in:
lib/dreck/exceptions.rb

Overview

Raised during argument absorption if arguments are either left over or are insufficient to populate the expected results.

Instance Method Summary collapse

Constructor Details

#initialize(actual, expected, greedy = false) ⇒ AbsorptionError

Returns a new instance of AbsorptionError.

Parameters:

  • actual (Integer)

    the actual number of arguments given

  • expected (Integer)

    the expected number of arguments

  • greedy (Boolean) (defaults to: false)

    whether or not a list that absorbs the tail is present



14
15
16
17
18
# File 'lib/dreck/exceptions.rb', line 14

def initialize(actual, expected, greedy = false)
  nmany = actual > expected ? "too few" : "too many"
  exp = greedy ? ">#{actual}" : expected
  super "#{nmany} arguments given (#{actual}, expected #{exp})"
end