Module: Tui::Tools

Defined in:
lib/tui/tools.rb

Overview

Various functions

Class Method Summary collapse

Class Method Details

.calc_width(value) ⇒ Object

Calculate width of a line / array of lines on console.

Code mainains width by +/- operations in the most cases, but sometimes it needs re-calculating it from scratch



9
10
11
12
13
14
# File 'lib/tui/tools.rb', line 9

def self.calc_width value
  case value
  when Array then value.collect { |row| Unicode::DisplayWidth.of(row) }.max
  when String then Unicode::DisplayWidth.of(value)
  end
end