Sha256: ca376c022c6bf541481cd888dc0e98f008110ed31d5f35669d077a287dc4e97d

Contents?: true

Size: 342 Bytes

Versions: 10

Compression:

Stored size: 342 Bytes

Contents

class String

  # Matches any whitespace (including newline) and replaces with a single space
  #
  # @example
  #   <<-QUERY.compress_lines
  #     SELECT name
  #     FROM users
  #   QUERY
  #   => "SELECT name FROM users"
  #
  def compress_lines(spaced = true)
    split($/).map { |line| line.strip }.join(spaced ? ' ' : '')
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/string/compress_lines.rb
facets-2.8.3 lib/core/facets/string/compress_lines.rb
facets-2.8.2 lib/core/facets/string/compress_lines.rb
facets-2.8.1 lib/core/facets/string/compress_lines.rb
facets-2.8.0 lib/core/facets/string/compress_lines.rb
facets-2.7.0 lib/core/facets/string/compress_lines.rb
facets-2.6.0 lib/core/facets/string/compress_lines.rb
facets-2.5.0 lib/core/facets/string/compress_lines.rb
facets-2.5.1 lib/core/facets/string/compress_lines.rb
facets-2.5.2 lib/core/facets/string/compress_lines.rb