Class: Cosmos::PacketTimeSecondsConversion

Inherits:
Conversion show all
Defined in:
lib/cosmos/conversions/packet_time_seconds_conversion.rb

Overview

Converts the packet received time into floating point seconds.

Instance Attribute Summary

Attributes inherited from Conversion

#converted_array_size, #converted_bit_size, #converted_type

Instance Method Summary collapse

Methods inherited from Conversion

#as_json, #to_config, #to_s

Constructor Details

#initializePacketTimeSecondsConversion

Initializes converted_type to :FLOAT and converted_bit_size to 64



26
27
28
29
30
# File 'lib/cosmos/conversions/packet_time_seconds_conversion.rb', line 26

def initialize
  super()
  @converted_type = :FLOAT
  @converted_bit_size = 64
end

Instance Method Details

#call(value, packet, buffer) ⇒ Float

Returns Packet received time in seconds.

Parameters:

  • value (Object)

    The value to convert

  • packet (Packet)

    The packet which contains the value. This can be useful to reach into the packet and use other values in the conversion.

  • buffer (String)

    The packet buffer

Returns:

  • (Float)

    Packet received time in seconds



34
35
36
37
38
39
40
41
# File 'lib/cosmos/conversions/packet_time_seconds_conversion.rb', line 34

def call(value, packet, buffer)
  packet_time = packet.packet_time
  if packet_time
    return packet_time.to_f
  else
    return 0.0
  end
end