Exception: KXI::Exceptions::OutOfRangeException
- Inherits:
-
Exception
- Object
- Exception
- KXI::Exceptions::OutOfRangeException
- Defined in:
- lib/kxi/exceptions/out_of_range_exception.rb
Overview
Raised when certain value is out of range
Instance Method Summary collapse
-
#initialize(val, min = nil, max = nil) ⇒ OutOfRangeException
constructor
Instantiates the OutOfRangeException class.
-
#maximum ⇒ Object?
Returns maximal expected value.
-
#minimum ⇒ Object?
Returns minimal expected value.
-
#value ⇒ Object
Returns erroneous value.
Constructor Details
#initialize(val, min = nil, max = nil) ⇒ OutOfRangeException
Note:
If both min and max are nil, then range is empty set
Instantiates the KXI::Exceptions::OutOfRangeException class
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/kxi/exceptions/out_of_range_exception.rb', line 30 def initialize(val, min = nil, max = nil) if min == nil and max == nil super("Value '#{val}' is out of range {}!") elsif min == max super("Value '#{val}' is out of range {#{min}}!") else super("Value '#{val}' is out of range #{(min == nil ? '(-∞' : "<#{min}")};#{(max == nil ? '∞)' : "#{max}>")}!") end @val = val @min = min @max = max end |
Instance Method Details
#maximum ⇒ Object?
Returns maximal expected value
21 22 23 |
# File 'lib/kxi/exceptions/out_of_range_exception.rb', line 21 def maximum @max end |
#minimum ⇒ Object?
Returns minimal expected value
15 16 17 |
# File 'lib/kxi/exceptions/out_of_range_exception.rb', line 15 def minimum @min end |
#value ⇒ Object
Returns erroneous value
9 10 11 |
# File 'lib/kxi/exceptions/out_of_range_exception.rb', line 9 def value @val end |