Calculates time after a given time. Default time is now. Reads best with argument: 10.minutes.after(time)
Returns the lower of self or x.
require 'facet/numeric/bound_by' 4.at_least(5) #=> 5 6.at_least(5) #=> 6
Returns the greater of self or x.
require 'facet/numeric/bound_by' 4.at_most(5) #=> 4 6.at_most(5) #=> 5
Calculates time before a given time. Default time is now. Reads best with arguments: 10.days.before( Time.now - 1.day )
Returns the value or the given upper or lower bound if the value falls outside of them.
require 'facet/comparable/bound_by' 4.bound_by(2,7) #=> 4 9.bound_by(2,7) #=> 7 1.bound_by(2,7) #=> 2
Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes. The base unit for all of these Numeric bytes methods is bytes. (One might expect it to be bits, but that doesn’t seem to be the general consensus.)
Alternate for comparison operator #<=>.
require 'facet/numeric/succ' 3.cmp(1) #=> 1 3.cmp(3) #=> 0 3.cmp(10) #=> -1
Returns the distance between self an another value. This is the same as #- but it provides an alternative for common naming between variant classes.
require 'facet/numeric/distance' 4.distance(3) #=> 1
Provides formated output of bytes proportial size.
require 'facet/numeric/octet_units' 1024.octet_units #=> "1.00 KB" 1048576.octet_units #=> "1.00 MB" 1073741824.octet_units #=> "1.00 GB" 1099511627776.octet_units #=> "1.00 TB"
Takes a format string to adjust output.
1024.octet_units('%.0f') #=> "1 KB"
Note: the name of this method will likely change in the future. But the best name has yet to be determined at this point.
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.