Sha256: 7fc798a55e8c5f97e8bcffae63ecb487752e700bf5e33f03d53575027cb8db35

Contents?: true

Size: 751 Bytes

Versions: 2

Compression:

Stored size: 751 Bytes

Contents

module GLI
  module Commands
    module HelpModules
      # Formats text in one line, stripping newlines and NOT wrapping
      class TTYOnlyWrapper
        # Args are ignored entirely; this keeps it consistent with the TextWrapper interface
        def initialize(width,indent)
          @proxy = if STDOUT.tty?
                     TextWrapper.new(width,indent)
                   else
                     NoWrappingWrapper.new(width,indent)
                   end
        end

        # Return a wrapped version of text, assuming that the first line has already been
        # indented by @indent characters.  Resulting text does NOT have a newline in it.
        def wrap(text)
          @proxy.wrap(text)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gli-2.2.1 lib/gli/commands/help_modules/tty_only_wrapper.rb
gli-2.2.0 lib/gli/commands/help_modules/tty_only_wrapper.rb