Exception: UnitMeasurements::UnitError

Inherits:
BaseError
  • Object
show all
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.

See Also:

Author:

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unit) ⇒ UnitError

Initializes a new UnitError instance.

Parameters:

  • unit (String)

    The name of the invalid unit.

Author:

Since:

  • 1.0.0



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

#unitString (readonly)

The name of the invalid unit.

Returns:

  • (String)

    The name of the invalid unit.

Author:

Since:

  • 1.0.0



22
23
24
# File 'lib/unit_measurements/errors/unit_error.rb', line 22

def unit
  @unit
end