Sha256: abc852f465a0bd81a9e7ffb20b56d0da83e5f6752ef5556f1f37ae99236e040a

Contents?: true

Size: 501 Bytes

Versions: 10

Compression:

Stored size: 501 Bytes

Contents

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.
  #
  #   %{ 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

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/string/squish.rb
facets-3.1.0 lib/core/facets/string/squish.rb
facets-3.0.0 lib/core/facets/string/squish.rb
facets-2.9.3 lib/core/facets/string/squish.rb
facets-2.9.2 lib/core/facets/string/squish.rb
facets-2.9.2 src/core/facets/string/squish.rb
facets-2.9.1 lib/core/facets/string/squish.rb
facets-2.9.0 lib/core/facets/string/squish.rb
facets-2.9.0.pre.2 lib/core/facets/string/squish.rb
facets-2.9.0.pre.1 lib/core/facets/string/squish.rb