Sha256: f3f700fc04abfb942497057afa09816948b9306186d610748c56b6d96ebe1f29
Contents?: true
Size: 761 Bytes
Versions: 26
Compression:
Stored size: 761 Bytes
Contents
unless String.method_defined? :squish class String # Strips leading and trailing whitespace and squashes internal whitespace. # # @return [String] a new string with no leading and trailing # whitespace and no consecutive whitespace characters inside it # # @example # ' Peter Parker'.squish #=> 'Peter Parker' def squish dup.squish! end # Strips leading and trailing whitespace and squashes internal whitespace. # # @return [String] the string with no leading and trailing whitespace and no # consecutive whitespace characters inside it # # @example # ' Peter Parker'.squish #=> 'Peter Parker' def squish! strip! gsub!(/\s+/, ' ') self end end end
Version data entries
26 entries across 23 versions & 6 rubygems