Class: Spektrum::Log::SpeedRecord
- Defined in:
- lib/spektrum/log/records.rb
Instance Attribute Summary
Attributes inherited from Record
Instance Method Summary collapse
-
#initialize(timestamp, raw_data) ⇒ SpeedRecord
constructor
A new instance of SpeedRecord.
-
#speed(unit = :knots) ⇒ Float
Gets the speed, in desired unit.
Methods inherited from Record
#raw_hex_string, #type, #valid?
Constructor Details
#initialize(timestamp, raw_data) ⇒ SpeedRecord
Returns a new instance of SpeedRecord.
327 328 329 |
# File 'lib/spektrum/log/records.rb', line 327 def initialize(, raw_data) super , raw_data end |
Instance Method Details
#speed(unit = :knots) ⇒ Float
Gets the speed, in desired unit.
335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/spektrum/log/records.rb', line 335 def speed(unit = :knots) @speed ||= two_byte_field(2..3) case unit when :knots @speed * 0.539957 when :mph @speed * 0.621371 when :kph @speed else @speed end end |