Sha256: a9f7522dec9946946e36e843141b8d5a29932d3997a03bc3d93e7f2d2a85b38b

Contents?: true

Size: 402 Bytes

Versions: 1

Compression:

Stored size: 402 Bytes

Contents

unless String.method_defined? :squish
  class String
    # Strips leading and trailing whitespace and squashes internal whitespace.
    #
    # @return [String] a string with not leading and traling whitespace and no
    # consecutive whitespace characters inside it
    #
    # @example
    #   ' Peter   Parker'.squish #=> 'Peter Parker'
    def squish
      strip.gsub(/\s+/, ' ')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
powerpack-0.0.3 lib/powerpack/string/squish.rb