aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_support_core_extensions.textile
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2009-11-01 19:50:21 +0100
committerXavier Noria <fxn@hashref.com>2009-11-01 19:50:21 +0100
commit738fd3d4a64c13523ce607357deae45d2f9a0ab5 (patch)
tree0bb42c7e715ec678d0e7ebbfe90d2a4fa064facf /railties/guides/source/active_support_core_extensions.textile
parent106b78d2efb39d8ea347e141eced61b70ca52618 (diff)
downloadrails-738fd3d4a64c13523ce607357deae45d2f9a0ab5.tar.gz
rails-738fd3d4a64c13523ce607357deae45d2f9a0ab5.tar.bz2
rails-738fd3d4a64c13523ce607357deae45d2f9a0ab5.zip
AS guide: documents Numeric#bytes and friends
Diffstat (limited to 'railties/guides/source/active_support_core_extensions.textile')
-rw-r--r--railties/guides/source/active_support_core_extensions.textile29
1 files changed, 28 insertions, 1 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index 147366c1a6..a2cfbff0ce 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -783,7 +783,34 @@ The call +str.last(n)+ is equivalent to +str.from(-n)+ if +n+ > 0, and returns a
h3. Extensions to +Numeric+
-...
+h4. Bytes
+
+All numbers respond to these methods:
+
+<ruby>
+bytes
+kilobytes
+megabytes
+gigabytes
+terabytes
+petabytes
+exabytes
+</ruby>
+
+They return the corresponding amount of bytes, using a conversion factor of 1024:
+
+<ruby>
+2.kilobytes # => 2048
+3.megabytes # => 3145728
+3.5.gigabytes # => 3758096384
+-4.exabytes # => -4611686018427387904
+</ruby>
+
+Singular forms are aliased so you are able to say:
+
+<ruby>
+1.megabyte # => 1024
+</ruby>
h3. Extensions to +Integer+