module StackMaster::Commands::TerminalHelper

Public Instance Methods

unix_window_size() click to toggle source
# File lib/stack_master/commands/terminal_helper.rb, line 16
def unix_window_size
  `tput cols`.chomp
end
window_size() click to toggle source
# File lib/stack_master/commands/terminal_helper.rb, line 6
def window_size
  size = ENV.fetch("COLUMNS") { OS.windows? ? windows_window_size : unix_window_size }

  if size.nil? || size == ""
    80
  else
    size.to_i
  end
end
windows_window_size() click to toggle source
# File lib/stack_master/commands/terminal_helper.rb, line 20
def windows_window_size
  columns_regex = %r{^\s+Columns:\s+([0-9]+)$}
  output = `mode con`
  columns_line = output.split("\n").select { |line| line.match(columns_regex) }.last
  columns_line.match(columns_regex)[1]
end