Class: Numeric
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
| Subclasses: 
          ActiveSupport::Duration::Scalar
         | |
| Inherits: | Object | 
| Defined in: | activesupport/lib/active_support/core_ext/object/json.rb, activesupport/lib/active_support/core_ext/numeric/bytes.rb, activesupport/lib/active_support/core_ext/numeric/time.rb, activesupport/lib/active_support/core_ext/object/blank.rb, activesupport/lib/active_support/core_ext/string/output_safety.rb | 
Constant Summary
- 
    EXABYTE =
    
 # File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 9PETABYTE * 1024 
- 
    GIGABYTE =
    
 # File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 6MEGABYTE * 1024 
- 
    KILOBYTE =
    
 # File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 41024
- 
    MEGABYTE =
    
 # File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 5KILOBYTE * 1024 
- 
    PETABYTE =
    
 # File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 8TERABYTE * 1024 
- 
    TERABYTE =
    
 # File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 7GIGABYTE * 1024 
- 
    ZETTABYTE =
    
 # File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 10EXABYTE * 1024 
Instance Attribute Summary
- #html_safe? ⇒ Boolean readonly
Instance Method Summary
- 
    
      #byte  
    
    Alias for #bytes. 
- 
    
      #bytes  
      (also: #byte)
    
    Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes. 
- 
    
      #day  
    
    Alias for #days. 
- 
    
      #days  
      (also: #day)
    
    Returns a Duration instance matching the number of days provided. 
- 
    
      #exabyte  
    
    Alias for #exabytes. 
- 
    
      #exabytes  
      (also: #exabyte)
    
    Returns the number of bytes equivalent to the exabytes provided. 
- 
    
      #fortnight  
    
    Alias for #fortnights. 
- 
    
      #fortnights  
      (also: #fortnight)
    
    Returns a Duration instance matching the number of fortnights provided. 
- 
    
      #gigabyte  
    
    Alias for #gigabytes. 
- 
    
      #gigabytes  
      (also: #gigabyte)
    
    Returns the number of bytes equivalent to the gigabytes provided. 
- 
    
      #hour  
    
    Alias for #hours. 
- 
    
      #hours  
      (also: #hour)
    
    Returns a Duration instance matching the number of hours provided. 
- 
    
      #in_milliseconds  
    
    Returns the number of milliseconds equivalent to the seconds provided. 
- 
    
      #kilobyte  
    
    Alias for #kilobytes. 
- 
    
      #kilobytes  
      (also: #kilobyte)
    
    Returns the number of bytes equivalent to the kilobytes provided. 
- 
    
      #megabyte  
    
    Alias for #megabytes. 
- 
    
      #megabytes  
      (also: #megabyte)
    
    Returns the number of bytes equivalent to the megabytes provided. 
- 
    
      #minute  
    
    Alias for #minutes. 
- 
    
      #minutes  
      (also: #minute)
    
    Returns a Duration instance matching the number of minutes provided. 
- 
    
      #petabyte  
    
    Alias for #petabytes. 
- 
    
      #petabytes  
      (also: #petabyte)
    
    Returns the number of bytes equivalent to the petabytes provided. 
- 
    
      #second  
    
    Alias for #seconds. 
- 
    
      #seconds  
      (also: #second)
    
    Returns a Duration instance matching the number of seconds provided. 
- 
    
      #terabyte  
    
    Alias for #terabytes. 
- 
    
      #terabytes  
      (also: #terabyte)
    
    Returns the number of bytes equivalent to the terabytes provided. 
- 
    
      #week  
    
    Alias for #weeks. 
- 
    
      #weeks  
      (also: #week)
    
    Returns a Duration instance matching the number of weeks provided. 
- 
    
      #zettabyte  
    
    Alias for #zettabytes. 
- 
    
      #zettabytes  
      (also: #zettabyte)
    
    Returns the number of bytes equivalent to the zettabytes provided. 
Instance Attribute Details
    #html_safe?  ⇒ Boolean  (readonly)
  
  [ GitHub ]
# File 'activesupport/lib/active_support/core_ext/string/output_safety.rb', line 13
def html_safe? true end
Instance Method Details
#byte
Alias for #bytes.
# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 18
alias :byte :bytes
#bytes Also known as: #byte
Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
2.bytes # => 2# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 15
def bytes self end
#day
Alias for #days.
# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 40
alias :day :days
#days Also known as: #day
Returns a Duration instance matching the number of days provided.
2.days # => 2 days# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 37
def days ActiveSupport::Duration.days(self) end
#exabyte
Alias for #exabytes.
# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 66
alias :exabyte :exabytes
#exabytes Also known as: #exabyte
Returns the number of bytes equivalent to the exabytes provided.
2.exabytes # => 2_305_843_009_213_693_952# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 63
def exabytes self * EXABYTE end
#fortnight
Alias for #fortnights.
# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 56
alias :fortnight :fortnights
#fortnights Also known as: #fortnight
Returns a Duration instance matching the number of fortnights provided.
2.fortnights # => 4 weeks# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 53
def fortnights ActiveSupport::Duration.weeks(self * 2) end
#gigabyte
Alias for #gigabytes.
# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 42
alias :gigabyte :gigabytes
#gigabytes Also known as: #gigabyte
Returns the number of bytes equivalent to the gigabytes provided.
2.gigabytes # => 2_147_483_648# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 39
def gigabytes self * GIGABYTE end
#hour
Alias for #hours.
# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 32
alias :hour :hours
#hours Also known as: #hour
Returns a Duration instance matching the number of hours provided.
2.hours # => 2 hours# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 29
def hours ActiveSupport::Duration.hours(self) end
#in_milliseconds
Returns the number of milliseconds equivalent to the seconds provided. Used with the standard time durations.
2.in_milliseconds # => 2000
1.hour.in_milliseconds # => 3600000# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 63
def in_milliseconds self * 1000 end
#kilobyte
Alias for #kilobytes.
# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 26
alias :kilobyte :kilobytes
#kilobytes Also known as: #kilobyte
Returns the number of bytes equivalent to the kilobytes provided.
2.kilobytes # => 2048# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 23
def kilobytes self * KILOBYTE end
#megabyte
Alias for #megabytes.
# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 34
alias :megabyte :megabytes
#megabytes Also known as: #megabyte
Returns the number of bytes equivalent to the megabytes provided.
2.megabytes # => 2_097_152# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 31
def megabytes self * MEGABYTE end
#minute
Alias for #minutes.
# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 24
alias :minute :minutes
#minutes Also known as: #minute
Returns a Duration instance matching the number of minutes provided.
2.minutes # => 2 minutes# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 21
def minutes ActiveSupport::Duration.minutes(self) end
#petabyte
Alias for #petabytes.
# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 58
alias :petabyte :petabytes
#petabytes Also known as: #petabyte
Returns the number of bytes equivalent to the petabytes provided.
2.petabytes # => 2_251_799_813_685_248# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 55
def petabytes self * PETABYTE end
#second
Alias for #seconds.
# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 16
alias :second :seconds
#seconds Also known as: #second
Returns a Duration instance matching the number of seconds provided.
2.seconds # => 2 seconds# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 13
def seconds ActiveSupport::Duration.seconds(self) end
#terabyte
Alias for #terabytes.
# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 50
alias :terabyte :terabytes
#terabytes Also known as: #terabyte
Returns the number of bytes equivalent to the terabytes provided.
2.terabytes # => 2_199_023_255_552# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 47
def terabytes self * TERABYTE end
#week
Alias for #weeks.
# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 48
alias :week :weeks
#weeks Also known as: #week
Returns a Duration instance matching the number of weeks provided.
2.weeks # => 2 weeks# File 'activesupport/lib/active_support/core_ext/numeric/time.rb', line 45
def weeks ActiveSupport::Duration.weeks(self) end
#zettabyte
Alias for #zettabytes.
# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 74
alias :zettabyte :zettabytes
#zettabytes Also known as: #zettabyte
Returns the number of bytes equivalent to the zettabytes provided.
2.zettabytes # => 2_361_183_241_434_822_606_848# File 'activesupport/lib/active_support/core_ext/numeric/bytes.rb', line 71
def zettabytes self * ZETTABYTE end