aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/numeric/bytes.rb
diff options
context:
space:
mode:
authorclaudiob <claudiob@gmail.com>2014-12-17 16:22:47 -0800
committerclaudiob <claudiob@gmail.com>2014-12-17 16:22:47 -0800
commit78789b7acd566562b58e73a7d4f1a11163370f32 (patch)
tree158daf78dea9a6d4a687bd5cffb8075b4b43fa4b /activesupport/lib/active_support/core_ext/numeric/bytes.rb
parenta4069cdb4253c4db880bac8dcbb7378e8a0053c3 (diff)
downloadrails-78789b7acd566562b58e73a7d4f1a11163370f32.tar.gz
rails-78789b7acd566562b58e73a7d4f1a11163370f32.tar.bz2
rails-78789b7acd566562b58e73a7d4f1a11163370f32.zip
Add docs for Numeric#*_bytes methods
Add docs for `kilobytes`, `megabytes`, `gigabytes`, `terabytes`, `petabytes` and `exabytes`. Fix docs for `bytes`. [ci skip]
Diffstat (limited to 'activesupport/lib/active_support/core_ext/numeric/bytes.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/numeric/bytes.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/numeric/bytes.rb b/activesupport/lib/active_support/core_ext/numeric/bytes.rb
index deea8e9358..9996320958 100644
--- a/activesupport/lib/active_support/core_ext/numeric/bytes.rb
+++ b/activesupport/lib/active_support/core_ext/numeric/bytes.rb
@@ -7,36 +7,56 @@ class Numeric
EXABYTE = PETABYTE * 1024
# Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
+ #
+ # 2.bytes #=> 2
def bytes
self
end
alias :byte :bytes
+ # Returns the number of bytes equivalent to the kilobytes provided.
+ #
+ # 2.kilobytes #=> 2048
def kilobytes
self * KILOBYTE
end
alias :kilobyte :kilobytes
+ # Returns the number of bytes equivalent to the megabytes provided.
+ #
+ # 2.megabytes #=> 2_097_152
def megabytes
self * MEGABYTE
end
alias :megabyte :megabytes
+ # Returns the number of bytes equivalent to the gigabytes provided.
+ #
+ # 2.gigabytes #=> 2_147_483_648
def gigabytes
self * GIGABYTE
end
alias :gigabyte :gigabytes
+ # Returns the number of bytes equivalent to the terabytes provided.
+ #
+ # 2.terabytes #=> 2_199_023_255_552
def terabytes
self * TERABYTE
end
alias :terabyte :terabytes
+ # Returns the number of bytes equivalent to the petabytes provided.
+ #
+ # 2.petabytes #=> 2_251_799_813_685_248
def petabytes
self * PETABYTE
end
alias :petabyte :petabytes
+ # Returns the number of bytes equivalent to the exabytes provided.
+ #
+ # 2.exabytes #=> 2_305_843_009_213_693_952
def exabytes
self * EXABYTE
end