Class: ProgressBar

Class | ProgressBar
In: | lib/more/facets/progressbar.rb
Parent: | Object

# ProgressBar

ProgressBar is a text-based progressbar library.

      pbar = ProgressBar.new( "Demo", 100 )
      100.times { pbar.inc }
      pbar.finish

### Methods

bar_mark= file_transfer_mode finish flush format= format_arguments= halt inc inspect new set title= total_overflow=

### Public Class methods

new(title, total, out = STDERR)

[Source]

    # File lib/more/facets/progressbar.rb, line 38
      def initialize(title, total, out = STDERR)
        @title = title
        @total = total
        @out = out
        @bar_length = 80
        @bar_mark = "o"
        @total_overflow = true
        @current = 0
        @previous = 0
        @is_finished = false
        @start_time = Time.now
        @format = "%-14s %3d%% %s %s"
        @format_arguments = [:title, :percentage, :bar, :stat]
        show_progress
      end

### Public Instance methods

bar_mark=(mark)

[Source]

    # File lib/more/facets/progressbar.rb, line 189
      def bar_mark=(mark)
        @bar_mark = String(mark)[0..0]
      end

file_transfer_mode()

[Source]

    # File lib/more/facets/progressbar.rb, line 181
      def file_transfer_mode
        @format_arguments = [:title, :percentage, :bar, :stat_for_file_transfer]
      end

finish()

[Source]

    # File lib/more/facets/progressbar.rb, line 205
      def finish
        @current = @total
        @is_finished = true
        show_progress
      end

flush()

[Source]

    # File lib/more/facets/progressbar.rb, line 211
      def flush
        @out.flush
      end

format=(format)

[Source]

    # File lib/more/facets/progressbar.rb, line 197
      def format=(format)
        @format = format
      end

format_arguments=(arguments)

[Source]

    # File lib/more/facets/progressbar.rb, line 201
      def format_arguments=(arguments)
        @format_arguments = arguments
      end

halt()

[Source]

    # File lib/more/facets/progressbar.rb, line 215
      def halt
        @is_finished = true
        show_progress
      end

inc(step = 1)

[Source]

    # File lib/more/facets/progressbar.rb, line 235
      def inc(step = 1)
        @current += step
        @current = @total if @current > @total
        show_progress
        @previous = @current
      end

inspect()

[Source]

    # File lib/more/facets/progressbar.rb, line 242
      def inspect
        "(ProgressBar: #{@current}/#{@total})"
      end

set(count)

[Source]

    # File lib/more/facets/progressbar.rb, line 220
      def set(count)
        if count < 0
          raise "invalid count less than zero: #{count}"
        elsif count > @total
          if @total_overflow
            @total = count + 1
          else
            raise "invalid count greater than total: #{count}"
          end
        end
        @current = count
        show_progress
        @previous = @current
      end

title=(str)

[Source]

    # File lib/more/facets/progressbar.rb, line 185
      def title=(str)
        @title = str
      end

total_overflow=(boolv)

[Source]

    # File lib/more/facets/progressbar.rb, line 193
      def total_overflow=(boolv)
        @total_overflow = boolv ? true : false
      end

[Validate]