Class: Van::Units::IECBinaryLoader

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

Constant Summary collapse

BINARY_IEC_PREFIXES =

The prefixes used for binary units in the IEC system. See also Converter#register_binary_iec_unit.

{
  'yobi'  => {:abbrev => 'Yi', :multiplier => 1024.0 ** 8},
  'zebi'  => {:abbrev => 'Zi', :multiplier => 1024.0 ** 7},
  'exbi'  => {:abbrev => 'Ei', :multiplier => 1024.0 ** 6},
  'pebi'  => {:abbrev => 'Pi', :multiplier => 1024.0 ** 5},
  'tebi'  => {:abbrev => 'Ti', :multiplier => 1024.0 ** 4},
  'gibi'  => {:abbrev => 'Gi', :multiplier => 1024.0 ** 3},
  'mebi'  => {:abbrev => 'Mi', :multiplier => 1024.0 ** 2},
  'kibi'  => {:abbrev => 'ki', :multiplier => 1024.0},

  '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},
}

Instance Method Summary collapse

Methods inherited from Loader

handles, method_added

Instance Method Details

#binary_iec_unit(converter, name, *args) ⇒ Object



104
105
106
# File 'lib/van/units/units.rb', line 104

def binary_iec_unit(converter, name, *args)
  converter.send(:register_prefixed_unit, name, BINARY_IEC_PREFIXES, *args)
end