lib/more/facets/multipliers.rb in facets-2.4.5 vs lib/more/facets/multipliers.rb in facets-2.5.0
- old
+ new
@@ -1,34 +1,21 @@
# = Multipliers
#
-# WARNING: Use Rich Units package for future compatibilty!
-#
# == Synopsis
#
-# Adds methods to Numeric to make working with
-# magnitudes (kilo, mega, giga, milli, micro, etc.)
-# as well as bits and bytes easier.
+# Adds methods to Numeric to make working with magnitudes
+# (kilo, mega, giga, milli, micro, etc.)
#
-# 1.kilo #=> 1000
-# 1.milli #=> 0.001
-# 1.kibi #=> 1024
-#
-# To display a value in a certain denomination, simply
-# perform the inverse operation by placing the
-# multiplier called on unit (1) in the denominator.
-#
-# 1000 / 1.kilo #=> 1
-# 1024 / 1.kibi #=> 1
-#
# == History
#
# Thanks to Rich Kilmer and bytes.rb which inspired this library.
#
# == Notes
#
# * This library is not compatible with STICK's units.rb (an spin-off
-# of Facets old units.rb library). Do not attempt to use both at the same time.
+# of Facets old units.rb library). Do not attempt to use both at
+# the same time.
#
# == Authors
#
# * Thomas Sawyer
#
@@ -43,67 +30,68 @@
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
-
-# = Multipliers
#
-# Adds methods to Numeric to make working with
-# magnitudes (kilo, mega, giga, milli, micro, etc.)
-# as well as bits and bytes easier.
-#
-# 1.kilo #=> 1000
-# 1.milli #=> 0.001
-# 1.kibi #=> 1024
-#
-# To display a value in a certain denomination, simply
-# perform the inverse operation by placing the
-# multiplier called on unit (1) in the denominator.
-#
-# 1000 / 1.kilo #=> 1
-# 1024 / 1.kibi #=> 1
-#
-
-#
class Numeric
- # SI Multipliers
+ # = Multipliers
+ #
+ # Adds methods to Numeric to make working with
+ # magnitudes (kilo, mega, giga, milli, micro, etc.)
+ #
+ # 1.kilo #=> 1000
+ # 1.milli #=> 0.001
+ # 1.kibi #=> 1024
+ #
+ # To display a value in a certain denomination, simply
+ # perform the inverse operation by placing the
+ # multiplier called on unit (1) in the denominator.
+ #
+ # 1000 / 1.kilo #=> 1
+ # 1024 / 1.kibi #=> 1
+ #
+ module Multipliers
- def deka ; self * 10 ; end
- def hecto ; self * 100 ; end
- def kilo ; self * 1000 ; end
- def mega ; self * 1000000 ; end
- def giga ; self * 1000000000 ; end
- def tera ; self * 1000000000000 ; end
- def peta ; self * 1000000000000000 ; end
- def exa ; self * 1000000000000000000 ; end
+ # SI Multipliers
- # SI Fractional
+ def deka ; self * 10 ; end
+ def hecto ; self * 100 ; end
+ def kilo ; self * 1000 ; end
+ def mega ; self * 1000000 ; end
+ def giga ; self * 1000000000 ; end
+ def tera ; self * 1000000000000 ; end
+ def peta ; self * 1000000000000000 ; end
+ def exa ; self * 1000000000000000000 ; end
- def deci ; self.to_f / 10 ; end
- def centi ; self.to_f / 100 ; end
- def milli ; self.to_f / 1000 ; end
- def micro ; self.to_f / 1000000 ; end
- def nano ; self.to_f / 1000000000 ; end
- def pico ; self.to_f / 1000000000000 ; end
- def femto ; self.to_f / 1000000000000000 ; end
- def atto ; self.to_f / 1000000000000000000 ; end
+ # SI Fractional
- # SI Binary
+ def deci ; self.to_f / 10 ; end
+ def centi ; self.to_f / 100 ; end
+ def milli ; self.to_f / 1000 ; end
+ def micro ; self.to_f / 1000000 ; end
+ def nano ; self.to_f / 1000000000 ; end
+ def pico ; self.to_f / 1000000000000 ; end
+ def femto ; self.to_f / 1000000000000000 ; end
+ def atto ; self.to_f / 1000000000000000000 ; end
- def kibi ; self * 1024 ; end
- def mebi ; self * 1024**2 ; end
- def gibi ; self * 1024**3 ; end
- def tebi ; self * 1024**4 ; end
- def pebi ; self * 1024**5 ; end
- def exbi ; self * 1024**6 ; end
+ # SI Binary
- # Bits and Bytes
+ def kibi ; self * 1024 ; end
+ def mebi ; self * 1024**2 ; end
+ def gibi ; self * 1024**3 ; end
+ def tebi ; self * 1024**4 ; end
+ def pebi ; self * 1024**5 ; end
+ def exbi ; self * 1024**6 ; end
- #def bit ; self ; end
- #def bits ; self ; end
- #def byte ; self * 8 ; end
- #def bytes ; self * 8 ; end
+ # Bits and Bytes
+ #def bit ; self ; end
+ #def bits ; self ; end
+ #def byte ; self * 8 ; end
+ #def bytes ; self * 8 ; end
+ end
+
+ include Multipliers
end