X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=vendor%2Frails%2Factivesupport%2Flib%2Factive_support%2Fcore_ext%2Fstring%2Ffilters.rb;fp=vendor%2Frails%2Factivesupport%2Flib%2Factive_support%2Fcore_ext%2Fstring%2Ffilters.rb;h=0329fbb8d4e3b2edb13e9982a4a41ae0ef36de2e;hb=437aa336c44c74a30aeea16a06743c32747ed661;hp=0000000000000000000000000000000000000000;hpb=97a0772b06264134cfe38e7494f9427efe0840a0;p=feedcatcher.git diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb new file mode 100644 index 0000000..0329fbb --- /dev/null +++ b/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb @@ -0,0 +1,26 @@ +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 + + # Performs a destructive squish. See String#squish. + def squish! + strip! + gsub!(/\s+/, ' ') + self + end + end + end + end +end