Class: Headway::Progress
- Inherits:
-
Object
- Object
- Headway::Progress
- 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
- #completed? ⇒ Boolean
- #formatted_percentage ⇒ Object
-
#initialize ⇒ Progress
constructor
A new instance of Progress.
- #percentage ⇒ Object
- #set_complete ⇒ Object
- #set_percentage(percentage) ⇒ Object
- #start_multistage_process(stages:) ⇒ Object
Constructor Details
Instance Method Details
#completed? ⇒ Boolean
33 34 35 |
# File 'lib/headway/progress.rb', line 33 def completed? current_stage.nil? end |
#formatted_percentage ⇒ Object
16 17 18 |
# File 'lib/headway/progress.rb', line 16 def formatted_percentage sprintf('%.1f%', percentage) end |
#percentage ⇒ Object
12 13 14 |
# File 'lib/headway/progress.rb', line 12 def percentage @root_stage.percentage end |
#set_complete ⇒ Object
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 |