Module: CLI::UI::Terminal
- Defined in:
- lib/cli/ui/terminal.rb
Constant Summary collapse
- DEFAULT_WIDTH =
80
- DEFAULT_HEIGHT =
24
Class Method Summary collapse
- .height ⇒ Object
-
.width ⇒ Object
Returns the width of the terminal, if possible Otherwise will return 80.
Class Method Details
.height ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cli/ui/terminal.rb', line 24 def self.height if console = IO.respond_to?(:console) && IO.console height = console.winsize[0] height.zero? ? DEFAULT_HEIGHT : height else DEFAULT_HEIGHT end rescue Errno::EIO DEFAULT_HEIGHT end |
.width ⇒ Object
Returns the width of the terminal, if possible Otherwise will return 80
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cli/ui/terminal.rb', line 13 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 |