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/positive.rb
lib/core/facets/numeric/round.rb
lib/core/facets/numeric/spacing.rb
lib/core/facets/object/dup.rb
lib/standard/facets/multipliers.rb
lib/standard/facets/random.rb
Parent: Object

Methods

approx?   blank?   clone?   close?   distance   dup!   dup?   length   negative?   positive?   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.

Currently defaults to 1/10,000,000 if the degree is not specified. But this may change once a "most commonly useful" factor is determined.

This is the same a {close?} but has a different defualt.

@author Gavin Sinclair

Determines if another number is approximately equal within a given epsilon.

This is the same a {approx?} but has a different defualt.

@author Gavin Sinclair

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.

Is a number less than zero.

Is a number greater than zero.

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]