summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Brown <gregory.t.brown@gmail.com>2009-02-02 14:06:53 -0500
committerGregory Brown <gregory.t.brown@gmail.com>2009-02-02 14:06:53 -0500
commitea6f286f0804466072d2c2f45cf558023bb7db1b (patch)
treef043b5cce6695d8f714307dfddf9f4cffde6ec7c
parent6a4e7ce4f6f7098a724bdb0ee2716c1d72441689 (diff)
downloadhighline-ea6f286f0804466072d2c2f45cf558023bb7db1b.tar.gz
Switch lines shim to each_line
-rw-r--r--lib/highline.rb2
-rw-r--r--lib/highline/compatibility.rb6
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