Class: RoadToRubykaigi::CalibrationSampler
- Inherits:
-
Object
- Object
- RoadToRubykaigi::CalibrationSampler
- Defined in:
- lib/road_to_rubykaigi/calibration_sampler.rb
Constant Summary collapse
- PHASE_SECONDS =
5
Instance Attribute Summary collapse
-
#cadences ⇒ Object
readonly
Returns the value of attribute cadences.
-
#intensities ⇒ Object
readonly
Returns the value of attribute intensities.
-
#intensity ⇒ Object
readonly
Returns the value of attribute intensity.
-
#raw_samples ⇒ Object
readonly
Returns the value of attribute raw_samples.
Instance Method Summary collapse
Instance Attribute Details
#cadences ⇒ Object (readonly)
Returns the value of attribute cadences.
5 6 7 |
# File 'lib/road_to_rubykaigi/calibration_sampler.rb', line 5 def cadences @cadences end |
#intensities ⇒ Object (readonly)
Returns the value of attribute intensities.
5 6 7 |
# File 'lib/road_to_rubykaigi/calibration_sampler.rb', line 5 def intensities @intensities end |
#intensity ⇒ Object (readonly)
Returns the value of attribute intensity.
5 6 7 |
# File 'lib/road_to_rubykaigi/calibration_sampler.rb', line 5 def intensity @intensity end |
#raw_samples ⇒ Object (readonly)
Returns the value of attribute raw_samples.
5 6 7 |
# File 'lib/road_to_rubykaigi/calibration_sampler.rb', line 5 def raw_samples @raw_samples end |
Instance Method Details
#finished? ⇒ Boolean
20 21 22 |
# File 'lib/road_to_rubykaigi/calibration_sampler.rb', line 20 def finished? elapsed >= PHASE_SECONDS end |
#progress ⇒ Object
28 29 30 |
# File 'lib/road_to_rubykaigi/calibration_sampler.rb', line 28 def progress (elapsed / PHASE_SECONDS.to_f).clamp(0.0, 1.0) end |
#remaining ⇒ Object
24 25 26 |
# File 'lib/road_to_rubykaigi/calibration_sampler.rb', line 24 def remaining PHASE_SECONDS - elapsed end |
#tick ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/road_to_rubykaigi/calibration_sampler.rb', line 7 def tick Config.signal_source.drain do |data| sample = parse_sample(data) next unless sample @window.buffer_sample(sample) @raw_samples << sample end return unless @window.full? @intensity = @window.motion_intensity @intensities << @intensity @cadences << @window.cadence_hz if @window.cadence_ready? end |