Class: Totalizer::Step
- Inherits:
-
Object
- Object
- Totalizer::Step
- Defined in:
- lib/totalizer/step.rb
Instance Attribute Summary collapse
-
#end_ids ⇒ Object
Returns the value of attribute end_ids.
-
#start_ids ⇒ Object
Returns the value of attribute start_ids.
Instance Method Summary collapse
- #finish ⇒ Object
- #ids ⇒ Object
-
#initialize(start_ids, end_ids) ⇒ Step
constructor
A new instance of Step.
- #rate ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(start_ids, end_ids) ⇒ Step
Returns a new instance of Step.
5 6 7 8 9 |
# File 'lib/totalizer/step.rb', line 5 def initialize start_ids, end_ids self.start_ids = start_ids self.end_ids = end_ids validate! end |
Instance Attribute Details
#end_ids ⇒ Object
Returns the value of attribute end_ids.
3 4 5 |
# File 'lib/totalizer/step.rb', line 3 def end_ids @end_ids end |
#start_ids ⇒ Object
Returns the value of attribute start_ids.
3 4 5 |
# File 'lib/totalizer/step.rb', line 3 def start_ids @start_ids end |
Instance Method Details
#finish ⇒ Object
23 24 25 |
# File 'lib/totalizer/step.rb', line 23 def finish ids.size end |
#ids ⇒ Object
15 16 17 |
# File 'lib/totalizer/step.rb', line 15 def ids @ids ||= calculate end |
#rate ⇒ Object
11 12 13 |
# File 'lib/totalizer/step.rb', line 11 def rate (finish.to_f/(start.to_f.nonzero? || 1)).round(2) end |
#start ⇒ Object
19 20 21 |
# File 'lib/totalizer/step.rb', line 19 def start start_ids.size end |