Sha256: 8de891e258c59e132781fe2cbea0c74df8be358811fcc947d8ed48f7979b76d1

Contents?: true

Size: 431 Bytes

Versions: 43

Compression:

Stored size: 431 Bytes

Contents

# 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

Version data entries

43 entries across 42 versions & 7 rubygems

Version Path
io-console-0.6.0 lib/io/console/size.rb
io-console-0.6.0-java lib/io/console/size.rb
io-console-0.5.11-java lib/io/console/size.rb
io-console-0.5.11 lib/io/console/size.rb
io-console-0.5.9 lib/io/console/size.rb
io-console-0.5.9-java lib/io/console/size.rb
io-console-0.5.8 lib/io/console/size.rb
io-console-0.5.8-java lib/io/console/size.rb
io-console-0.5.7 lib/io/console/size.rb
io-console-0.5.7-java lib/io/console/size.rb
io-console-0.5.6 lib/io/console/size.rb
io-console-0.5.5 lib/io/console/size.rb
io-console-0.5.4 lib/io/console/size.rb
io-console-0.5.3 lib/io/console/size.rb
io-console-0.5.2 lib/io/console/size.rb
io-console-0.5.0 lib/io/console/size.rb
io-console-0.4.9 lib/io/console/size.rb
io-console-0.4.8-x86-mingw32 lib/io/console/size.rb
io-console-0.4.8-x64-mingw32 lib/io/console/size.rb
io-console-0.4.8 lib/io/console/size.rb