Module: EasyIO::Terminal
- Defined in:
- lib/easy_io/terminal.rb
Class Method Summary collapse
- .columns ⇒ Object
-
.dimensions ⇒ Object
returns [rows, columns].
- .interactive? ⇒ Boolean
- .line(filler_character) ⇒ Object
- .rows ⇒ Object
-
.sync_output ⇒ Object
Forces real-time output.
Class Method Details
.columns ⇒ Object
25 26 27 |
# File 'lib/easy_io/terminal.rb', line 25 def columns dimensions.last end |
.dimensions ⇒ Object
returns [rows, columns]
12 13 14 15 16 17 18 19 |
# File 'lib/easy_io/terminal.rb', line 12 def dimensions require 'io/console' IO.console.winsize rescue LoadError # This works with older Ruby, but only with systems # that have a tput(1) command, such as Unix clones. [Integer(`tput li`), Integer(`tput co`)] end |
.interactive? ⇒ Boolean
33 34 35 |
# File 'lib/easy_io/terminal.rb', line 33 def interactive? $stdout.isatty end |
.line(filler_character) ⇒ Object
29 30 31 |
# File 'lib/easy_io/terminal.rb', line 29 def line(filler_character) filler_character * (Terminal.columns - 1) end |
.rows ⇒ Object
21 22 23 |
# File 'lib/easy_io/terminal.rb', line 21 def rows dimensions.first end |
.sync_output ⇒ Object
Forces real-time output
6 7 8 9 |
# File 'lib/easy_io/terminal.rb', line 6 def sync_output $stdout.sync = true $stderr.sync = true end |