Class: String

Inherits:
Object show all
Defined in:
lib/sinatra/support/compat-1.8.6.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) lines(separator = $/)

This version of String#lines is almost fully compatible with that of Ruby 1.9. If a zero-length record separator is supplied in Ruby 1.9, the string is split into paragraphs delimited by multiple successive newlines. This replacement ignores that feature in favor of code simplicity.



12
13
14
15
16
# File 'lib/sinatra/support/compat-1.8.6.rb', line 12

def lines(separator = $/)
  result = split(separator).map { |part| "#{part}#{separator}" }
  result.each { |r| yield r } if block_given?
  result
end