Method: PowerBar::Rate#append
- Defined in:
- lib/powerbar.rb
#append(at, v) ⇒ Object
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/powerbar.rb', line 390 def append(at, v) return if @sample_interval > at - @last_sample_at @sample_interval += @sample_interval_step_up if @sample_interval < @sample_interval_max rate = (v - @counter) / (at - @last_sample_at).to_f return if rate.nan? @last_sample_at = at @counter = v self << rate shift while @window < length self end |