class Headway::Progress

Constants

COMPLETE_PERCENT
START_PERCENT

Public Class Methods

new() click to toggle source
# File lib/headway/progress.rb, line 7
def initialize
  @root_stage = Stage.new
  @current_stage_index = 0
end

Public Instance Methods

completed?() click to toggle source
# File lib/headway/progress.rb, line 33
def completed?
  current_stage.nil?
end
formatted_percentage() click to toggle source
# File lib/headway/progress.rb, line 16
def formatted_percentage
  sprintf('%.1f%', percentage)
end
percentage() click to toggle source
# File lib/headway/progress.rb, line 12
def percentage
  @root_stage.percentage
end
set_complete() click to toggle source
# File lib/headway/progress.rb, line 28
def set_complete
  current_stage.set_percentage 100.0
  @current_stage_index += 1
end
set_percentage(percentage) click to toggle source
# File lib/headway/progress.rb, line 20
def set_percentage(percentage)
  current_stage.set_percentage percentage
end
start_multistage_process(stages:) click to toggle source
# File lib/headway/progress.rb, line 24
def start_multistage_process(stages:)
  current_stage.promote_to_multistage stages: stages
end

Private Instance Methods

current_stage() click to toggle source
# File lib/headway/progress.rb, line 39
def current_stage
  stages.flatten[@current_stage_index]
end
stages() click to toggle source
# File lib/headway/progress.rb, line 43
def stages
  Array(@root_stage.stages)
end