Sha256: 50137a42aea53f82cd8fb792d332b903549eb0ac69f6d4c4613cf3e201d70c48

Contents?: true

Size: 790 Bytes

Versions: 13

Compression:

Stored size: 790 Bytes

Contents

module DataMapper; module Ext
  module 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"
    #
    # @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
    def self.compress_lines(string, spaced = true)
      string.split($/).map { |line| line.strip }.join(spaced ? ' ' : '')
    end
  end
end; end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
sbf-dm-core-1.5.0 lib/dm-core/support/ext/string.rb
sbf-dm-core-1.4.0 lib/dm-core/support/ext/string.rb
sbf-dm-core-1.3.0 lib/dm-core/support/ext/string.rb
sbf-dm-core-1.3.0.beta lib/dm-core/support/ext/string.rb
ardm-core-1.3.0 lib/dm-core/support/ext/string.rb
ardm-core-1.2.1 lib/dm-core/support/ext/string.rb
dm-core-1.2.1 lib/dm-core/support/ext/string.rb
ghost_dm-core-1.3.0.beta lib/dm-core/support/ext/string.rb
dm-core-1.2.0 lib/dm-core/support/ext/string.rb
dm-core-1.2.0.rc2 lib/dm-core/support/ext/string.rb
dm-core-1.2.0.rc1 lib/dm-core/support/ext/string.rb
dm-core-1.1.0 lib/dm-core/support/ext/string.rb
dm-core-1.1.0.rc3 lib/dm-core/ext/string.rb