Sha256: e80bfc82684e8f322f964c4bd1ab7a1691e7944af7b5f8d3ee8411e0e503ecfe

Contents?: true

Size: 393 Bytes

Versions: 3

Compression:

Stored size: 393 Bytes

Contents

# frozen_string_literal: true

require 'progress'

# Add times_with_progress method to Integer
class Integer
  # run `times` with progress
  #   100.times_with_progress('Numbers') do |number|
  #     # code
  #   end
  def times_with_progress(title = nil)
    Progress.start(title, self) do
      times do |i|
        Progress.step do
          yield i
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
progress-3.6.0 lib/progress/integer.rb
progress-3.5.2 lib/progress/integer.rb
progress-3.5.1 lib/progress/integer.rb