Class: Progression::Progress
- Inherits:
-
Object
- Object
- Progression::Progress
- Defined in:
- lib/progression.rb
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #completed_steps ⇒ Object
-
#initialize(object, steps) ⇒ Progress
constructor
A new instance of Progress.
- #next_step ⇒ Object
- #percentage_completed ⇒ Object
Constructor Details
#initialize(object, steps) ⇒ Progress
Returns a new instance of Progress.
46 47 48 49 |
# File 'lib/progression.rb', line 46 def initialize(object, steps) @object = object @steps = steps end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
44 45 46 |
# File 'lib/progression.rb', line 44 def steps @steps end |
Instance Method Details
#completed_steps ⇒ Object
51 52 53 54 55 |
# File 'lib/progression.rb', line 51 def completed_steps steps.select do |step| step.evaluate(@object) end end |
#next_step ⇒ Object
61 62 63 64 65 |
# File 'lib/progression.rb', line 61 def next_step steps.find do |step| !step.evaluate(@object) end end |
#percentage_completed ⇒ Object
57 58 59 |
# File 'lib/progression.rb', line 57 def percentage_completed (completed_steps.size / steps.size.to_f) * 100 end |