../lib/numru/gphys/unumeric.rb

# 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

## Methods

#### `val`

  RETURN VALUE

  - the value (Numric)

#### `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 if $VERBOSE).

  EXCEPTION

  - none

  WARING MADE

  When $VERBOSE==true, 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

  When $VERBOSE==true, 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 +.