diff options
author | Gregory Brown <gregory.t.brown@gmail.com> | 2009-02-02 14:06:53 -0500 |
---|---|---|
committer | Gregory Brown <gregory.t.brown@gmail.com> | 2009-02-02 14:06:53 -0500 |
commit | ea6f286f0804466072d2c2f45cf558023bb7db1b (patch) | |
tree | f043b5cce6695d8f714307dfddf9f4cffde6ec7c | |
parent | 6a4e7ce4f6f7098a724bdb0ee2716c1d72441689 (diff) | |
download | highline-ea6f286f0804466072d2c2f45cf558023bb7db1b.tar.gz |
Switch lines shim to each_line
-rw-r--r-- | lib/highline.rb | 2 | ||||
-rw-r--r-- | lib/highline/compatibility.rb | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/highline.rb b/lib/highline.rb index d7df281..f6cc63a 100644 --- a/lib/highline.rb +++ b/lib/highline.rb @@ -727,7 +727,7 @@ class HighLine # def wrap( text ) wrapped = [ ] - text.lines.each do |line| + text.each_line do |line| while line =~ /([^\n]{#{@wrap_at + 1},})/ search = $1.dup replace = $1.dup diff --git a/lib/highline/compatibility.rb b/lib/highline/compatibility.rb index 9da82ed..bcb4e25 100644 --- a/lib/highline/compatibility.rb +++ b/lib/highline/compatibility.rb @@ -8,10 +8,12 @@ unless STDIN.respond_to?(:getbyte) end end -unless "".respond_to?(:lines) +unless "".respond_to?(:each_line) # Not a perfect translation, but sufficient for our needs. class String - alias_method :lines, :to_a + def each_line + to_a.each { |line| yield(line) } + end end end |