Exception: UnitMeasurements::UnitError
- Defined in:
- lib/unit_measurements/errors/unit_error.rb
Overview
The UnitMeasurements::UnitError
class is used to indicate that an invalid unit was encountered. The error message states that the unit is invalid and provides the name of the problematic unit.
This error is raised when the unit is not defined within the unit group.
Instance Attribute Summary collapse
-
#unit ⇒ String
readonly
The name of the invalid unit.
Instance Method Summary collapse
-
#initialize(unit) ⇒ UnitError
constructor
Initializes a new
UnitError
instance.
Constructor Details
#initialize(unit) ⇒ UnitError
Initializes a new UnitError
instance.
30 31 32 33 34 |
# File 'lib/unit_measurements/errors/unit_error.rb', line 30 def initialize(unit) @unit = unit super("Invalid unit: '#{unit}'.") end |
Instance Attribute Details
#unit ⇒ String (readonly)
The name of the invalid unit.
22 23 24 |
# File 'lib/unit_measurements/errors/unit_error.rb', line 22 def unit @unit end |