Class: Okei::Unit

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Uuids::Base
Defined in:
app/models/okei/unit.rb

Overview

Stores and validates units of measure.

Attributes:

uuids

list of Units::Uuid objects assigned (referred to) the unit.

code

literal cyrillic code (“КМ/Ч”).

name

name of the unit (“Километры в час”).

num

numeric code of the unit following the OKEI (“007”).

int_code

a literal international code of the unit (“KMH”).

base

literal cyrillic code of the basic unit of measure (“М/С”).

factor

float number of basic units in a current unit (0.28).

measure

the name of measurement (“СКОРОСТЬ”) used for filtering units.

Methods:

#uuid

returns value of the first uuids assigned to the unit.

.by_uuid(value)

selects units by a given UUID.

The first UUID can be set manually if necessary (when db populated from the outer list). Otherwise it will be assigned by default on the unit creation.

Examples:

unit = Unit.new(
  name: "Километры в час", code: "КМ/Ч", num: "007", int_code: "KMH",
  base: "М/С", factor: 0.28, measure: "СКОРОСТЬ"
  uuid: "9ac7e74a-d51a-424c-8fcd-71b0b55f6658"
)

Constant Summary collapse

NUM_FORMAT =

Format of OKEI numeric codes (three digits).

/\A\d{3}\z/