Class Numeric
In: lib/core/facets/boolean.rb
lib/core/facets/kernel/blank.rb
lib/core/facets/numeric/approx.rb
lib/core/facets/numeric/distance.rb
lib/core/facets/numeric/length.rb
lib/core/facets/numeric/round.rb
lib/core/facets/numeric/spacing.rb
lib/core/facets/object/dup.rb
lib/more/facets/multipliers.rb
lib/more/facets/random.rb
Parent: Object

Methods

approx?   blank?   clone?   distance   dup!   dup?   length   round_at   round_to   spacing   to_b  

Included Modules

Multipliers Random::NumericExtensions

Classes and Modules

Module Numeric::Multipliers

Public Instance methods

Determines if another number is approximately equal within a given _n_th degree. Defaults to 100ths if the degree is not specified.

CREDIT: Trans

Returns the distance between self an another value. This is the same as #- but it provides an alternative for common naming between variant classes.

  4.distance(3)  #=> 1

Since Numeric is immutable it cannot be duplicated. For this reason try_dup returns self.

  1.dup!  #=> 1

Returns self, useful for polymorphic cases.

Conceptually, rounding is expected to apply to floating point numbers. However it can actually be applied to pretty much any Numeric object. For example, one could round an Integer to the nearest kilo.

See Float#round_at.

Returns the size of the string representation of a numerical value.

     1.spacing   #=> 1
    10.spacing   #=> 2
   100.spacing   #=> 3
  -100.spacing   #=> 4
   1.2.spacing   #=> 3

CREDIT: Victor H. Goff III

Provides a boolean interpretation of self. If self == 0 then false else true.

  0.to_b    #=> false
  1.to_b    #=> true
  2.3.to_b  #=> true

[Validate]