Class: Numeric
 Inherits:

Object
 Object
 Numeric
 Defined in:
 lib/magician/numeric.rb
Overview
Magician's extensions to the Numeric class (affects Integers and Floats).
Instance Method Summary collapse

#digits(selection) ⇒ Integer
deprecated
Deprecated.
Avoid using this any more. It's inaccurate and not very useful.

#divisible?(n) ⇒ Boolean
Returns true if the number is evenly divisible by n.

#to_degrees ⇒ Numeric
Converts the number from radians to degrees and returns the result.

#to_radians ⇒ Numeric
Converts the number from degrees to radians and returns the result.
Instance Method Details
#digits(selection) ⇒ Integer
Deprecated.
Avoid using this any more. It's inaccurate and not very useful.
Performs to_s.to_i on the number. Note that for floats, the decimal counts as a digit within the string.
25 26 27 
# File 'lib/magician/numeric.rb', line 25 def digits selection to_s[selection].to_i end 
#divisible?(n) ⇒ Boolean
Returns true if the number is evenly divisible by n. If n is equal to 0, it returns false, since numbers cannot be divided by 0 in real number arithmetic.
11 12 13 
# File 'lib/magician/numeric.rb', line 11 def divisible? n not n.zero? and modulo(n).zero? end 