Module: DataMapper::Ext::String
- Defined in:
- lib/dm-core/support/ext/string.rb
Class Method Summary collapse
-
.compress_lines(string, spaced = true) ⇒ String
Replace sequences of whitespace (including newlines) with either a single space or remove them entirely (according to param spaced).
Class Method Details
.compress_lines(string, spaced = true) ⇒ String
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"
20 21 22 |
# 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 |