Module: CLI::UI::Terminal

Defined in:
lib/cli/ui/terminal.rb

Constant Summary collapse

DEFAULT_WIDTH =
80

Class Method Summary collapse

Class Method Details

.widthObject

Returns the width of the terminal, if possible Otherwise will return 80



12
13
14
15
16
17
18
19
20
21
# File 'lib/cli/ui/terminal.rb', line 12

def self.width
  if console = IO.respond_to?(:console) && IO.console
    width = console.winsize[1]
    width.zero? ? DEFAULT_WIDTH : width
  else
    DEFAULT_WIDTH
  end
rescue Errno::EIO
  DEFAULT_WIDTH
end