Method: UnitMeasurements::Unit#names

Defined in:
lib/unit_measurements/unit.rb

#namesArray<String>

Returns an array containing the name of the unit and its aliases, sorted alphabetically.

Examples:

UnitMeasurements::Length.new(1, "m").unit.names
=> ["m", "meter", "meters", "metre", "metres"]

Returns:

  • (Array<String>)

    An array of unit names.

Author:

Since:

  • 1.0.0



107
108
109
# File 'lib/unit_measurements/unit.rb', line 107

def names
  (aliases + [name]).sort.freeze
end