diff options
author | Xavier Noria <fxn@hashref.com> | 2009-08-23 01:23:56 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2009-08-23 01:23:56 +0200 |
commit | 49a23ad4218e2b37eb3a77091b26eb9308246e39 (patch) | |
tree | 0eab5ac7cddd27d7cbd2066ba8900fff8d215e1c /railties/guides/source/active_support_overview.textile | |
parent | db41df2cd1a1165c6071aa5c8ca1f8ea0c744a23 (diff) | |
download | rails-49a23ad4218e2b37eb3a77091b26eb9308246e39.tar.gz rails-49a23ad4218e2b37eb3a77091b26eb9308246e39.tar.bz2 rails-49a23ad4218e2b37eb3a77091b26eb9308246e39.zip |
AS guide: documents String#squish
Diffstat (limited to 'railties/guides/source/active_support_overview.textile')
-rw-r--r-- | railties/guides/source/active_support_overview.textile | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_overview.textile b/railties/guides/source/active_support_overview.textile index 65ec023876..5e6c2030c6 100644 --- a/railties/guides/source/active_support_overview.textile +++ b/railties/guides/source/active_support_overview.textile @@ -682,6 +682,16 @@ h4. +bytesize+ Ruby 1.9 introduces +String#bytesize+ to obtain the length of a string in bytes. Ruby 1.8.7 defines this method as an alias for +String#size+ for forward compatibility, and Active Support does so for previous versions. +h4. +squish+ + +The method +String#squish+ strips leading and trailing whitespace, and substitutes runs of whitespace with a single space each: + +<ruby> +" \n foo\n\r \t bar \n".squish # => "foo bar" +</ruby> + +There's also the destructive version +String#squish!+. + h3. Extensions to +Numeric+ ... |