Class: Headway::Progress

Inherits:
Object
  • Object
show all
Defined in:
lib/headway/progress.rb

Defined Under Namespace

Classes: Stage

Constant Summary collapse

START_PERCENT =
0.0
COMPLETE_PERCENT =
100.0

Instance Method Summary collapse

Constructor Details

#initializeProgress

Returns a new instance of Progress.



7
8
9
10
# File 'lib/headway/progress.rb', line 7

def initialize
  @root_stage = Stage.new
  @current_stage_index = 0
end

Instance Method Details

#completed?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/headway/progress.rb', line 33

def completed?
  current_stage.nil?
end

#formatted_percentageObject



16
17
18
# File 'lib/headway/progress.rb', line 16

def formatted_percentage
  sprintf('%.1f%', percentage)
end

#percentageObject



12
13
14
# File 'lib/headway/progress.rb', line 12

def percentage
  @root_stage.percentage
end

#set_completeObject



28
29
30
31
# File 'lib/headway/progress.rb', line 28

def set_complete
  current_stage.set_percentage 100.0
  @current_stage_index += 1
end

#set_percentage(percentage) ⇒ Object



20
21
22
# File 'lib/headway/progress.rb', line 20

def set_percentage(percentage)
  current_stage.set_percentage percentage
end

#start_multistage_process(stages:) ⇒ Object



24
25
26
# File 'lib/headway/progress.rb', line 24

def start_multistage_process(stages:)
  current_stage.promote_to_multistage stages: stages
end