Sha256: d32542569694b8e1d45a0804c3a29f296e795be196683e478a5baac85f29c782

Contents?: true

Size: 893 Bytes

Versions: 5

Compression:

Stored size: 893 Bytes

Contents

module Oldtime
  class UI
    def warn(message)
    end

    def debug(message)
    end

    def error(message)
    end

    def info(message)
    end

    def confirm(message)
    end

    # alias to info.
    def say(*args, &blk)
      info(*args, &blk)
    end

    class Shell < UI
      attr_writer :shell

      def initialize(shell)
        @shell = shell
        @quiet = false
        @debug = ENV['DEBUG']
      end

      def debug(msg)
        @shell.say(msg) if @debug && !@quiet
      end

      def info(msg)
        @shell.say(msg) if !@quiet
      end

      def confirm(msg)
        @shell.say(msg, :green) if !@quiet
      end

      def warn(msg)
        @shell.say(msg, :yellow)
      end

      def error(msg)
        @shell.say(msg, :red)
      end

      def be_quiet!
        @quiet = true
      end

      def debug!
        @debug = true
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oldtime-0.1.3 lib/oldtime/ui.rb
oldtime-0.1.2 lib/oldtime/ui.rb
oldtime-0.1.1 lib/oldtime/ui.rb
oldtime-0.1.0 lib/oldtime/ui.rb
oldtime-0.0.1 lib/oldtime/ui.rb