Skip to content

Commit bd860b8

Browse files
committedMar 27, 2018
Actually add size.rb. rails/rails#32318.
1 parent b3ba7e3 commit bd860b8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
 

Diff for: ‎lib/ruby/stdlib/io/console/size.rb

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: false
2+
# fallback to console window size
3+
def IO.default_console_size
4+
[
5+
ENV["LINES"].to_i.nonzero? || 25,
6+
ENV["COLUMNS"].to_i.nonzero? || 80,
7+
]
8+
end
9+
10+
begin
11+
require 'io/console'
12+
rescue LoadError
13+
class << IO
14+
alias console_size default_console_size
15+
end
16+
else
17+
# returns console window size
18+
def IO.console_size
19+
console.winsize
20+
rescue NoMethodError
21+
default_console_size
22+
end
23+
end

0 commit comments

Comments
 (0)
Please sign in to comment.