Exception: UnitMeasurements::UnitAlreadyDefinedError

Inherits:
BaseError
  • Object
show all
Defined in:
lib/unit_measurements/errors/unit_already_defined_error.rb

Overview

The UnitMeasurements::UnitAlreadyDefinedError class is used to indicate that an attempt was made to define a unit that has already been defined within a unit group.

The error message states that the unit is already defined and provides the name of the conflicting unit.

See Also:

Author:

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unit) ⇒ UnitAlreadyDefinedError

Initializes a new UnitAlreadyDefinedError instance.

Parameters:

  • unit (String)

    The name of the unit that is already defined.

Author:

Since:

  • 1.0.0



31
32
33
34
35
# File 'lib/unit_measurements/errors/unit_already_defined_error.rb', line 31

def initialize(unit)
  @unit = unit

  super("Unit already defined: '#{unit}'.")
end

Instance Attribute Details

#unitString (readonly)

The name of the unit that is already defined.

Returns:

  • (String)

    The name of the unit that is already defined.

Author:

Since:

  • 1.0.0



23
24
25
# File 'lib/unit_measurements/errors/unit_already_defined_error.rb', line 23

def unit
  @unit
end