Class: Stick::Units::SILoader

Inherits:
Loader
  • Object
show all
Defined in:
lib/stick/units/units.rb

Constant Summary collapse

SI_PREFIXES =

The prefixes used for SI units. See also Converter#register_si_unit.

{
  'yotta' => {:abbrev => 'Y',  :multiplier => 1e24},
  'zetta' => {:abbrev => 'Z',  :multiplier => 1e21},
  'exa'   => {:abbrev => 'E',  :multiplier => 1e18},
  'peta'  => {:abbrev => 'P',  :multiplier => 1e14},
  'tera'  => {:abbrev => 'T',  :multiplier => 1e12},
  'giga'  => {:abbrev => 'G',  :multiplier => 1e9},
  'mega'  => {:abbrev => 'M',  :multiplier => 1e6},
  'kilo'  => {:abbrev => 'k',  :multiplier => 1e3},
  'hecto' => {:abbrev => 'h',  :multiplier => 1e2},
  'deca'  => {:abbrev => 'da', :multiplier => 1e1},
  'deci'  => {:abbrev => 'd',  :multiplier => 1e-1},
  'centi' => {:abbrev => 'c',  :multiplier => 1e-2},
  'milli' => {:abbrev => 'm',  :multiplier => 1e-3},
  'micro' => {:abbrev => 'u',  :multiplier => 1e-6},
  'nano'  => {:abbrev => 'n',  :multiplier => 1e-9},
  'pico'  => {:abbrev => 'p',  :multiplier => 1e-12},
  'femto' => {:abbrev => 'f',  :multiplier => 1e-15},
  'atto'  => {:abbrev => 'a',  :multiplier => 1e-18},
  'zepto' => {:abbrev => 'z',  :multiplier => 1e-21},
  'yocto' => {:abbrev => 'y',  :multiplier => 1e-24}
}

Instance Method Summary collapse

Methods inherited from Loader

handles, method_added

Instance Method Details

#si_unit(converter, name, args) ⇒ Object



34
35
36
# File 'lib/stick/units/units.rb', line 34

def si_unit(converter, name, args)
  converter.send(:register_prefixed_unit, name, SI_PREFIXES, args)
end