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

after(time = ::Time.now)

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

approx?( x, n=0.01 )

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

atto()
before(time = ::Time.now)

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

bit()
bit()

Bits and Bytes

bits()
bits()
byte()
byte()
bytes()
bytes()
ceil_multiple(multiple)

Returns the multiple ceil of a number.

centi()
day()

Alias for days

days()

Converts days into seconds.

deci()

SI Fractional

deka()

SI Multipliers

distance( other )

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

exa()
exbi()
femto()
fortnight()

Alias for fortnights

fortnights()

Converts fortnights into seconds. (A fortnight is 2 weeks)

from_now(time = ::Time.now)

Alias for after

gibi()
giga()
hecto()
hour()

Alias for hours

hours()

Converts hours into seconds.

kibi()

SI Binary

kilo()
later(time = ::Time.now)

Alias for after

mebi()
mega()
method_missing(m, *args, &blk)
micro()
milli()
minute()

Alias for minutes

minutes()

Converts minutes into seconds.

month()

Alias for months

months()

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

nano()
octet_units(fmt='%.2f')

Alias for strfbytes

pebi()
peta()
pico()
pred(n=nil)

Provides pred as the opposite of succ.

      3.pred(2)  #=> 1

round_at(*args)

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

round_to(*args)

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

second()

Alias for seconds

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

strfbits(fmt='%.2f')

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"

strfbytes(fmt='%.2f')

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"

succ(n=nil)

Allows succ to take n increments.

      3.succ(2)  #=> 5

tebi()
tera()
to_b()

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

weekdays()

Works with day in terms of weekdays.

weeks()

Converts weeks into seconds.

year()

Alias for years

years()

Converts years into seconds.

[Validate]