# class NumRu::UNumeric

Class of Numeric with Units.

Dependent on NumRu::Units and Rational, a standard library.

## Class Methods

#### `new(val, uni)`

  Constractor.

  ARGUMENTS

  - val (Numeric)
  - units (NumRu::Units or String): if string, internally converted to a NumRu::Units

#### `[val, uni]`

  Same as new

#### `from_date(date, units)`

  Convert a DateTime (or Date) to a UNUmeric

  ARGUMENTS

  - date (Date or DateTime)
  - units (Units or String) : units of the UNumeric to be created

## Methods

#### `val`

  RETURN VALUE
  - the value (Numeric)

#### `units`

  RETURN VALUE
  - the units (NumRu::Units)

#### `inspect`

  RETURN VALUE
  - a String (e.g., '1 m')

#### `to_s`

  aliasesed to inspect.

#### `to_f`

  RETURN VALUE
  - val.to_f

#### `to_i`

  RETURN VALUE
  - val.to_i

#### `convert(to_units)`

  Convert to to_units.

  RETURN VALUE

  - a UNumeric

  EXCEPTION

  - when the current units is incompatible with to_units.

#### `convert2`

  Same as convert, but returns self if the units are incompatible (Warned).

  EXCEPTION

  - none

  WARING MADE

  Warning is made to $stderr if the following condition is satisfied.

  - the units of self and to_units are incompatible.

#### `coerce(other)`

  As you know. Can handle Numeric, Array, NArray. NOTE: VArray and GPhys know UNumeric.

#### `*(other)`

  Multiplication. Knows Numeric, UNumeric, VArray, and GPhys. The units are multipled too. (if other is Numeric, it is assumed to be non-dimension)

  RETURN VALUE

  - a UNumeric, VArray, or GPhys

#### `/(other)`

  Division. See *.

#### `+(other)`

  Addition. Knows Numeric, UNumeric, VArray, and GPhys. The return value will have the units of self.

  SPECIAL REMARK!

  If other has units within a factor and/or offset of difference, It is CONVERTED before addition (by using convert2)!

  RETURN VALUE

  - a UNumeric, VArray, or GPhys

  WARING MADE

  Warning is made to $stderr if the following condition is satisfied.

  - the units of self and to_units are incompatible.
  - other is Numeric.

#### `-(other)`

  Subtraction. See +.

#### `**(num)`

  Power.

#### `abs`

  Absolute value. Other math functions are also avialable as instance methods.

#### `to_datetime(eps_sec=0.0)`

  Convert a time UNumeric into a DateTime

  ARGUMENTS

  - eps_sec (Float) : Magic epsilon to prevent the round-off of DateTime [seconds]. Recommended value is 0.1.

  RETURN VALUE

  - a DateTime

  EXCEPTION

  - raised if self does not have a time unit with a since field

#### `strftime(fmt)`

  Text expression of the date and time of a time UNumeric. Implemented as

      self.to_datetime(0.1).strftime(fmt)

  ARGUMENTS

  - fmt (Sting) : the format. Try

        % man 3 strftime

    to find how to write it.

  RETURN VALUE

  - a String