Class/Module Index [+]

Quicksearch

DataMapper::Ext::String

Public Class Methods

compress_lines(string, spaced = true) click to toggle source

Replace sequences of whitespace (including newlines) with either a single space or remove them entirely (according to param spaced).

compress_lines(<<QUERY)
  SELECT name
  FROM users
QUERY => "SELECT name FROM users"

@param [String] string

The input string.

@param [TrueClass, FalseClass] spaced (default=true)

Determines whether returned string has whitespace collapsed or removed.

@return [String] The input string with whitespace (including newlines) replaced.

@api semipublic

# File lib/dm-core/support/ext/string.rb, line 20
def self.compress_lines(string, spaced = true)
  string.split($/).map { |line| line.strip }.join(spaced ? ' ' : '')
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.