class Numeric
def as_json(options = nil) #:nodoc:
def as_json(options = nil) #:nodoc: self end
def blank?
-
(false)
-
def blank? false end
def bytes
Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
def bytes self end
def days
Returns a Duration instance matching the number of days provided.
def days ActiveSupport::Duration.days(self) end
def duplicable?
3.duplicable? # => false
Numbers are not duplicable:
def duplicable? false end
def exabytes
Returns the number of bytes equivalent to the exabytes provided.
def exabytes self * EXABYTE end
def fortnights
Returns a Duration instance matching the number of fortnights provided.
def fortnights ActiveSupport::Duration.weeks(self * 2) end
def gigabytes
Returns the number of bytes equivalent to the gigabytes provided.
def gigabytes self * GIGABYTE end
def hours
Returns a Duration instance matching the number of hours provided.
def hours ActiveSupport::Duration.hours(self) end
def html_safe?
def html_safe? true end
def in_milliseconds
so we can feed them to JavaScript functions like getTime().
Used with the standard time durations, like 1.hour.in_milliseconds --
Returns the number of milliseconds equivalent to the seconds provided.
def in_milliseconds self * 1000 end
def kilobytes
Returns the number of bytes equivalent to the kilobytes provided.
def kilobytes self * KILOBYTE end
def megabytes
Returns the number of bytes equivalent to the megabytes provided.
def megabytes self * MEGABYTE end
def minutes
Returns a Duration instance matching the number of minutes provided.
def minutes ActiveSupport::Duration.minutes(self) end
def negative?
0.negative? # => false
-1.negative? # => true
Returns true if the number is negative.
def negative? self < 0 end
def petabytes
Returns the number of bytes equivalent to the petabytes provided.
def petabytes self * PETABYTE end
def positive?
0.positive? # => false
1.positive? # => true
Returns true if the number is positive.
def positive? self > 0 end
def seconds
# equivalent to Time.current.advance(months: 4, years: 5)
2.years.from_now
# equivalent to Time.current.advance(years: 2)
1.month.from_now
# equivalent to Time.current.advance(months: 1)
as well as adding or subtracting their results from a Time object. For example:
These methods use Time#advance for precise date calculations when using from_now, ago, etc.
Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
def seconds ActiveSupport::Duration.seconds(self) end
def terabytes
Returns the number of bytes equivalent to the terabytes provided.
def terabytes self * TERABYTE end
def weeks
Returns a Duration instance matching the number of weeks provided.
def weeks ActiveSupport::Duration.weeks(self) end