Class: Progression::Progression
- Inherits:
-
Object
- Object
- Progression::Progression
- Defined in:
- lib/progression.rb
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Progression
constructor
A new instance of Progression.
- #percentage_value_for(step) ⇒ Object
- #progress_for(object) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Progression
Returns a new instance of Progression.
25 26 27 28 29 |
# File 'lib/progression.rb', line 25 def initialize(&block) @steps = [] @percentage_values = {} instance_exec &block if block_given? end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
23 24 25 |
# File 'lib/progression.rb', line 23 def steps @steps end |
Instance Method Details
#percentage_value_for(step) ⇒ Object
35 36 37 |
# File 'lib/progression.rb', line 35 def percentage_value_for(step) @percentage_values[step] || (1 / steps.size.to_f) * 100 end |