Sha256: a7bdfd8e2a8d2cce6eafe5c1e6d65f2922b66fdbace721e900ccfda7dee80a70
Contents?: true
Size: 836 Bytes
Versions: 14
Compression:
Stored size: 836 Bytes
Contents
module Pageflow module LinkmapPage class Progress def initialize(steps:, &block) @total_steps = steps @block = block @counter = 0 end def step return if counter >= total_steps @counter += 1 report(current_percent) end def divide(steps:) return if counter >= total_steps sub_progress = Progress.new(steps: steps) do |percent| if percent == 100 step else report(current_percent + percent / total_steps) end end yield sub_progress end private attr_reader :block, :total_steps, :counter def current_percent 100.0 / total_steps * counter end def report(percent) @block.call(percent) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems