Sha256: c13e2222f01bd7297c82bddd76fe1e65e2180dd306c383f399207f4770b38bb4

Contents?: true

Size: 882 Bytes

Versions: 4

Compression:

Stored size: 882 Bytes

Contents

module Saber
  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(message)
      info(message)
    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

4 entries across 4 versions & 1 rubygems

Version Path
saber-0.0.7 lib/saber/ui.rb
saber-0.0.6 lib/saber/ui.rb
saber-0.0.4 lib/saber/ui.rb
saber-0.0.3 lib/saber/ui.rb