Sha256: 9010bfff1c5cf840aea2b7b7c65bf6e101b78e860b45c63b2fa131ea42add677

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

# encoding: utf-8

require 'pastel'

module TTY
  class Command
    module Printers
      class Abstract
        extend Forwardable

        def_delegators :@color, :decorate

        attr_reader :output, :options

        # Initialize a Printer object
        #
        # @param [IO] output
        #   the printer output
        #
        # @api public
        def initialize(output, options = {})
          @output  = output
          @options = options
          @enabled  = options.fetch(:color) { true }
          @color   = ::Pastel.new(output: output, enabled: @enabled)
        end

        def print_command_start(cmd, *args)
          write(cmd.to_command + "#{args.join}")
        end

        def print_command_out_data(cmd, *args)
          write(args.join(' '))
        end

        def print_command_err_data(cmd, *args)
          write(args.join(' '))
        end

        def print_command_exit(cmd, *args)
          write(args.join(' '))
        end

        def write(message)
          raise NotImplemented, "Abstract printer cannot be used"
        end
      end # Abstract
    end # Printers
  end # Command
end # TTY

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tty-command-0.7.0 lib/tty/command/printers/abstract.rb
tty-command-0.6.0 lib/tty/command/printers/abstract.rb
tty-command-0.5.0 lib/tty/command/printers/abstract.rb
tty-command-0.4.0 lib/tty/command/printers/abstract.rb
tty-command-0.3.3 lib/tty/command/printers/abstract.rb
tty-command-0.3.2 lib/tty/command/printers/abstract.rb
tty-command-0.3.1 lib/tty/command/printers/abstract.rb
tty-command-0.3.0 lib/tty/command/printers/abstract.rb