Sha256: 2ce181f8817eed10d5fef974167299bcb5591ab0962997edbc925e9254938c87

Contents?: true

Size: 983 Bytes

Versions: 4

Compression:

Stored size: 983 Bytes

Contents

# -*- encoding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-

module UnitMeasurements
  # 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 BaseError
  # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
  # @since 1.0.0
  class UnitError < BaseError
    # The name of the invalid unit.
    #
    # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
    # @since 1.0.0
    attr_reader :unit

    # Initializes a new +UnitError+ instance.
    #
    # @param [String] unit The name of the invalid unit.
    #
    # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
    # @since 1.0.0
    def initialize(unit)
      @unit = unit

      super("Invalid unit: '#{unit}'.")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
unit_measurements-5.0.0 lib/unit_measurements/errors/unit_error.rb
unit_measurements-4.12.0 lib/unit_measurements/errors/unit_error.rb
unit_measurements-4.11.0 lib/unit_measurements/errors/unit_error.rb
unit_measurements-4.10.0 lib/unit_measurements/errors/unit_error.rb