Sha256: 79e1ad25785d916f16371cd57642d0323b7ff033313daca3d4566ce7074db843

Contents?: true

Size: 799 Bytes

Versions: 8

Compression:

Stored size: 799 Bytes

Contents

require_relative "term_width/detected"
require_relative "term_width/static"

module CutePrint
  
  # @api private
  class TermWidth

    # 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.
    # @param width [Object] Either the static terminal width,
    #   or :detect to automatically detect the terminal width.
    # @return [#width, #visible]
    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

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cute_print-1.4.0 lib/cute_print/term_width.rb
cute_print-1.3.0 lib/cute_print/term_width.rb
cute_print-1.2.0 lib/cute_print/term_width.rb
cute_print-1.1.4 lib/cute_print/term_width.rb
cute_print-1.1.3 lib/cute_print/term_width.rb
cute_print-1.1.2 lib/cute_print/term_width.rb
cute_print-1.1.1 lib/cute_print/term_width.rb
cute_print-1.1.0 lib/cute_print/term_width.rb