mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/io/console/lib/console/size.rb (IO#console_size): new
method. (EXPERIMENTAL) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
52f5f410e4
commit
aef01ee789
2 changed files with 25 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed May 18 22:45:26 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/io/console/lib/console/size.rb (IO#console_size): new
|
||||
method. (EXPERIMENTAL)
|
||||
|
||||
Wed May 18 22:41:51 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* internal.h: add for internal use only.
|
||||
|
|
20
ext/io/console/lib/console/size.rb
Normal file
20
ext/io/console/lib/console/size.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
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
|
||||
def IO.console_size
|
||||
console.winsize
|
||||
rescue NoMethodError
|
||||
default_console_size
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue