Class: CodelessCode::Renderers::TermWidth
- Inherits:
-
Object
- Object
- CodelessCode::Renderers::TermWidth
- Defined in:
- lib/codeless_code/renderers/term_page.rb
Overview
Ask an external application how wide our terminal is
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(cmd = 'tput cols') ⇒ TermWidth
constructor
A new instance of TermWidth.
Constructor Details
#initialize(cmd = 'tput cols') ⇒ TermWidth
Returns a new instance of TermWidth.
98 99 100 |
# File 'lib/codeless_code/renderers/term_page.rb', line 98 def initialize(cmd = 'tput cols') @cmd = cmd end |
Instance Method Details
#call ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/codeless_code/renderers/term_page.rb', line 102 def call if (tput_width = `#{@cmd}`.strip.to_i).positive? tput_width end rescue Errno::ENOENT nil end |