Class: CutePrint::TermWidth Private

Inherits:
Object show all
Defined in:
lib/cute_print/term_width.rb,
lib/cute_print/term_width/static.rb,
lib/cute_print/term_width/detected.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Detected, Static

Class Method Summary collapse

Class Method Details

.make(width) ⇒ #width, #visible

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Given a width, make an appropriate TermWidth object. The object returned has these readers:

  • #width [Integer] Return the actual terminal width

  • #visible [Object] Return the terminal width that #Configuration#term_width should return.

Parameters:

  • width (Object)

    Either the static terminal width, or :detect to automatically detect the terminal width.

Returns:

  • (#width, #visible)


17
18
19
20
21
22
23
24
25
26
# File 'lib/cute_print/term_width.rb', line 17

def self.make(width)
  case width
  when Integer
    Static.new(width)
  when :detect
    Detected.new
  else
    raise ArgumentError, "Invalid terminal width: #{width.inspect}"
  end
end