Class: Onboardable::List::Base
- Inherits:
-
Object
- Object
- Onboardable::List::Base
- Includes:
- Navigation
- Defined in:
- lib/onboardable/list/base.rb
Overview
The List class manages a sequence of steps in an onboarding process, tracking progress and current state.
Constant Summary collapse
- PROGRESS_CALCULATION =
->(step_index, steps_size) { (step_index.to_f / steps_size) * 100 }
Instance Attribute Summary collapse
-
#current_step ⇒ Step
readonly
The current step in the list.
-
#steps ⇒ Array<Step>
readonly
The steps in the list.
Instance Method Summary collapse
-
#initialize(steps, current_step, options = {}) ⇒ Base
constructor
Initializes a new instance of List with steps and a current step.
-
#progress(progress_calculation = nil) ⇒ Float
Calculates and returns the onboarding progress as a percentage.
Methods included from Navigation
#current_step?, #first_step, #first_step?, #last_step, #last_step?, #next_step, #next_step!, #next_step?, #prev_step, #prev_step!, #prev_step?
Constructor Details
#initialize(steps, current_step, options = {}) ⇒ Base
Initializes a new instance of List with steps and a current step.
22 23 24 25 26 |
# File 'lib/onboardable/list/base.rb', line 22 def initialize(steps, current_step, = {}) self.steps = steps self.current_step = current_step self. = end |
Instance Attribute Details
#current_step ⇒ Step
Returns The current step in the list.
15 16 17 |
# File 'lib/onboardable/list/base.rb', line 15 def current_step @current_step end |
#steps ⇒ Array<Step>
Returns The steps in the list.
12 13 14 |
# File 'lib/onboardable/list/base.rb', line 12 def steps @steps end |
Instance Method Details
#progress(progress_calculation = nil) ⇒ Float
Calculates and returns the onboarding progress as a percentage.
32 33 34 35 |
# File 'lib/onboardable/list/base.rb', line 32 def progress(progress_calculation = nil) progress_calculation ||= .fetch(:progress_calculation, PROGRESS_CALCULATION) Float(progress_calculation[step_index(current_step), steps.size]) end |