Exception: KXI::Exceptions::InvalidTypeException
- Inherits:
-
Exception
- Object
- Exception
- KXI::Exceptions::InvalidTypeException
- Defined in:
- lib/kxi/exceptions/invalid_type_exception.rb
Overview
Raised when some value is of unexpected type
Instance Method Summary collapse
-
#actual ⇒ Class
Returns actual type.
-
#expected ⇒ Array<Class>
Returns expected types.
-
#initialize(act, *exp) ⇒ InvalidTypeException
constructor
Instantiates the [KXI::Exceptions::InvalidTypeException] class.
Constructor Details
#initialize(act, *exp) ⇒ InvalidTypeException
Instantiates the [KXI::Exceptions::InvalidTypeException] class
22 23 24 25 26 27 28 29 30 |
# File 'lib/kxi/exceptions/invalid_type_exception.rb', line 22 def initialize(act, *exp) if exp.length == 1 super("Value is of unexpected type! Expected <#{exp[0].name}> got <#{act.name}>") else super("Value is of unexpected type! Expected { #{exp.collect {|i| "<#{i}>"}.join(', ')} } got <#{act.name}>") end @exp = exp @act = act end |
Instance Method Details
#actual ⇒ Class
Returns actual type
15 16 17 |
# File 'lib/kxi/exceptions/invalid_type_exception.rb', line 15 def actual @act end |
#expected ⇒ Array<Class>
Returns expected types
9 10 11 |
# File 'lib/kxi/exceptions/invalid_type_exception.rb', line 9 def expected @exp end |