Sha256: b79e367bfe60b713cc7e72fb88c3ee9f5d1969eef3747658eb8efd35faddf72b

Contents?: true

Size: 823 Bytes

Versions: 7

Compression:

Stored size: 823 Bytes

Contents

module Synx
  class Tabber

    @options = {}
    @tabbing = 0

    class << self
      def increase(n=1)
        @tabbing += n
      end

      def decrease(n=1)
       @tabbing -= n
       @tabbing = 0 if @tabbing < 0
      end

      def current
        @tabbing
      end

      def reset
        @tabbing = 0
        self.options = {}
      end

      def options=(options = {})
        @options = options
      end

      def options
        @options
      end

      def puts(str="")
        str = str.uncolorize if options[:no_color]
        output.puts (a_single_tab * @tabbing) + str.to_s unless options[:quiet]
      end

      def a_single_tab
        return "  "
      end
      private :a_single_tab

      def output
        options.fetch(:output, $stdout)
      end
      private :output

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
synx-0.2.1 lib/synx/tabber.rb
synx-0.2.0 lib/synx/tabber.rb
synx-0.1.1 lib/synx/tabber.rb
synx-0.1.0 lib/synx/tabber.rb
synx-0.0.61 lib/synx/tabber.rb
synx-0.0.54 lib/synx/tabber.rb
synx-0.0.53 lib/synx/tabber.rb