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=d115f2e23823271635bad69229a42cd8ac68debe;hp=0000000000000000000000000000000000000000;hpb=37cb670bf3ddde90b214e591f100ed4446469484;p=depot.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