Sha256: 259e965122e0bde80ede58bf162fd39f1f5705141990626750b96861632fe52d

Contents?: true

Size: 409 Bytes

Versions: 1

Compression:

Stored size: 409 Bytes

Contents

class String

  unless method_defined?(:lines)  # 1.8.7+

    # Returns an array of characters.
    #
    #   "abc\n123".lines  #=> ["abc","123"]
    #
    # Note, this is not 100% compatible with 1.8.7+
    # which returns an enumerator instead of an array.
    #
    def lines(&blk)
      if block_given?
        self.split(/\n/).each(&blk)
      else
        self.split(/\n/)
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-2.7.0 lib/core/facets/string/lines.rb