Class: Totalizer::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/totalizer/step.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idsObject

Returns the value of attribute end_ids.



3
4
5
# File 'lib/totalizer/step.rb', line 3

def end_ids
  @end_ids
end

#start_idsObject

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

#finishObject



23
24
25
# File 'lib/totalizer/step.rb', line 23

def finish
  ids.size
end

#idsObject



15
16
17
# File 'lib/totalizer/step.rb', line 15

def ids
  @ids ||= calculate
end

#rateObject



11
12
13
# File 'lib/totalizer/step.rb', line 11

def rate
  (finish.to_f/(start.to_f.nonzero? || 1)).round(2)
end

#startObject



19
20
21
# File 'lib/totalizer/step.rb', line 19

def start
  start_ids.size
end