Skip to content

Commit

Permalink
Actually add size.rb. rails/rails#32318.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Mar 27, 2018
1 parent b3ba7e3 commit bd860b8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/ruby/stdlib/io/console/size.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: false
# fallback to console window size
def IO.default_console_size
[
ENV["LINES"].to_i.nonzero? || 25,
ENV["COLUMNS"].to_i.nonzero? || 80,
]
end

begin
require 'io/console'
rescue LoadError
class << IO
alias console_size default_console_size
end
else
# returns console window size
def IO.console_size
console.winsize
rescue NoMethodError
default_console_size
end
end

0 comments on commit bd860b8

Please sign in to comment.