Class Numeric
In: lib/facets/more/bytes.rb
lib/facets/more/units.rb
lib/facets/more/multipliers.rb
lib/facets/more/times.rb
lib/facets/core/numeric/approx.rb
lib/facets/core/numeric/succ.rb
lib/facets/core/numeric/to_b.rb
lib/facets/core/numeric/ceil_multiple.rb
lib/facets/core/numeric/distance.rb
lib/facets/core/float/round_to.rb
lib/facets/core/float/round_at.rb
Parent: Object

Methods

after   ago   approx?   atto   before   bit   bit   bits   bits   byte   byte   bytes   bytes   ceil_multiple   centi   day   days   deci   deka   distance   exa   exbi   femto   fortnight   fortnights   from_now   gibi   giga   hecto   hour   hours   kibi   kilo   later   mebi   mega   method_missing   micro   milli   minute   minutes   month   months   nano   octet_units   pebi   peta   pico   pred   round_at   round_to   second   seconds   since   strfbits   strfbytes   succ   tebi   tera   to_b   until   week   weekday   weekdays   weeks   year   years  

Public Instance methods

Calculates time after a given time. Default time is now. Reads best with argument: 10.minutes.after(time)

ago(time = ::Time.now)

Alias for before

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

Calculates time before a given time. Default time is now. Reads best with arguments: 10.days.before( Time.now - 1.day )

Bits and Bytes

Returns the multiple ceil of a number.

day()

Alias for days

Converts days into seconds.

SI Fractional

SI Multipliers

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
fortnight()

Alias for fortnights

from_now(time = ::Time.now)

Alias for after

hour()

Alias for hours

Converts hours into seconds.

SI Binary

later(time = ::Time.now)

Alias for after

minute()

Alias for minutes

Converts minutes into seconds.

month()

Alias for months

Converts months into seconds. WARNING: This is not exact as it assumes 30 days to a month.

octet_units(fmt='%.2f')

Alias for strfbytes

Provides pred as the opposite of succ.

  3.pred(2)  #=> 1

To properly support Float‘s rounding methods, Numeric must also be augmented.

To properly support Float‘s rounding methods, Numeric must also be augmented.

second()

Alias for seconds

Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. The base unit for all of these Numeric time methods is seconds.

since(time = ::Time.now)

Alias for after

Formated string of bits proportial to size.

  1024.bits_to_s            #=> "1.00 kb"
  1048576.bits_to_s         #=> "1.00 mb"
  1073741824.bits_to_s      #=> "1.00 gb"
  1099511627776.bits_to_s   #=> "1.00 tb"

Takes a format string to adjust output.

  1024.bits_to_s('%.0f')    #=> "1 kb"

Formated string of bytes proportial to size.

  1024.bytes_to_s            #=> "1.00 KB"
  1048576.bytes_to_s         #=> "1.00 MB"
  1073741824.bytes_to_s      #=> "1.00 GB"
  1099511627776.bytes_to_s   #=> "1.00 TB"

Takes a format string to adjust output.

  1024.bytes_to_s('%.0f')    #=> "1 KB"

Allows succ to take n increments.

  3.succ(2)  #=> 5

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
until(time = ::Time.now)

Alias for before

week()

Alias for weeks

weekday()

Alias for weekdays

Works with day in terms of weekdays.

Converts weeks into seconds.

year()

Alias for years

Converts years into seconds.

[Validate]