Numeric
Skip to Content Skip to Search Menu Ruby on Rails 8.1.4.1 Class Numeric < Object 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/object/json.rb activesupport/lib/active_support/core_ext/string/output_safety.rb v8.1.4.1 Methods B byte , bytes D day , days E exabyte , exabytes F fortnight , fortnights G gigabyte , gigabytes H hour , hours , html_safe?
I in_milliseconds K kilobyte , kilobytes M megabyte , megabytes , minute , minutes P petabyte , petabytes S second , seconds T terabyte , terabytes W week , weeks Z zettabyte , zettabytes Constants EXABYTE = PETABYTE * 1024 GIGABYTE = MEGABYTE * 1024 KILOBYTE = 1024 MEGABYTE = KILOBYTE * 1024 PETABYTE = TERABYTE * 1024 TERABYTE = GIGABYTE * 1024 ZETTABYTE = EXABYTE * 1024 Instance Public methods byte () Link Alias for: bytes bytes () Link Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes 2 . bytes # => 2 Also aliased as: byte Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 15 def bytes self end day () Link Alias for: days days () Link Returns a Duration instance matching the number of days provided.
2 . days # => 2 days Also aliased as: day Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/time.rb, line 37 def days ActiveSupport :: Duration . days ( self ) end exabyte () Link Alias for: exabytes exabytes () Link Returns the number of bytes equivalent to the exabytes provided. 2 . exabytes # => 2_305_843_009_213_693_952 Also aliased as: exabyte Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 63 def exabytes self * EXABYTE end fortnight () Link Alias for: fortnights fortnights () Link Returns a Duration instance matching the number of fortnights provided.
2 . fortnights # => 4 weeks Also aliased as: fortnight Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/time.rb, line 53 def fortnights ActiveSupport :: Duration . weeks ( self * 2 ) end gigabyte () Link Alias for: gigabytes gigabytes () Link Returns the number of bytes equivalent to the gigabytes provided. 2 . gigabytes # => 2_147_483_648 Also aliased as: gigabyte Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 39 def gigabytes self * GIGABYTE end hour () Link Alias for: hours hours () Link Returns a Duration instance matching the number of hours provided.
2 . hours # => 2 hours Also aliased as: hour Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/time.rb, line 29 def hours ActiveSupport :: Duration . hours ( self ) end html_safe? () Link Source: show | on GitHub # File activesupport/lib/active_support/core_ext/string/output_safety.rb, line 13 def html_safe? true end in_milliseconds () Link 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 Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/time.rb, line 63 def in_milliseconds self * 1000 end kilobyte () Link Alias for: kilobytes kilobytes () Link Returns the number of bytes equivalent to the kilobytes provided. 2 . kilobytes # => 2048 Also aliased as: kilobyte Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 23 def kilobytes self * KILOBYTE end megabyte () Link Alias for: megabytes megabytes () Link Returns the number of bytes equivalent to the megabytes provided.
2 . megabytes # => 2_097_152 Also aliased as: megabyte Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 31 def megabytes self * MEGABYTE end minute () Link Alias for: minutes minutes () Link Returns a Duration instance matching the number of minutes provided. 2 . minutes # => 2 minutes Also aliased as: minute Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/time.rb, line 21 def minutes ActiveSupport :: Duration . minutes ( self ) end petabyte () Link Alias for: petabytes petabytes () Link Returns the number of bytes equivalent to the petabytes provided.
2 . petabytes # => 2_251_799_813_685_248 Also aliased as: petabyte Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 55 def petabytes self * PETABYTE end second () Link Alias for: seconds seconds () Link Returns a Duration instance matching the number of seconds provided. 2 . seconds # => 2 seconds Also aliased as: second Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/time.rb, line 13 def seconds ActiveSupport :: Duration . seconds ( self ) end terabyte () Link Alias for: terabytes terabytes () Link Returns the number of bytes equivalent to the terabytes provided.
2 . terabytes # => 2_199_023_255_552 Also aliased as: terabyte Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 47 def terabytes self * TERABYTE end week () Link Alias for: weeks weeks () Link Returns a Duration instance matching the number of weeks provided. 2 . weeks # => 2 weeks Also aliased as: week Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/time.rb, line 45 def weeks ActiveSupport :: Duration . weeks ( self ) end zettabyte () Link Alias for: zettabytes zettabytes () Link Returns the number of bytes equivalent to the zettabytes provided.
2 . zettabytes # => 2_361_183_241_434_822_606_848 Also aliased as: zettabyte Source: show | on GitHub # File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 71 def zettabytes self * ZETTABYTE end