Class: CodelessCode::Renderers::TermWidth

Inherits:
Object
  • Object
show all
Defined in:
lib/codeless_code/renderers/term_page.rb

Overview

Ask an external application how wide our terminal is

Instance Method Summary collapse

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

#callObject



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