diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/string/filters.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/filters.rb | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb index 0329fbb8d4..6fda7efef5 100644 --- a/activesupport/lib/active_support/core_ext/string/filters.rb +++ b/activesupport/lib/active_support/core_ext/string/filters.rb @@ -1,26 +1,20 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - module Filters - # Returns the string, first removing all whitespace on both ends of - # the string, and then changing remaining consecutive whitespace - # groups into one space each. - # - # Examples: - # %{ Multi-line - # string }.squish # => "Multi-line string" - # " foo bar \n \t boo".squish # => "foo bar boo" - def squish - dup.squish! - end +class String + # Returns the string, first removing all whitespace on both ends of + # the string, and then changing remaining consecutive whitespace + # groups into one space each. + # + # Examples: + # %{ Multi-line + # string }.squish # => "Multi-line string" + # " foo bar \n \t boo".squish # => "foo bar boo" + def squish + dup.squish! + end - # Performs a destructive squish. See String#squish. - def squish! - strip! - gsub!(/\s+/, ' ') - self - end - end - end + # Performs a destructive squish. See String#squish. + def squish! + strip! + gsub!(/\s+/, ' ') + self end end |