Class: Cosmos::UnixTimeSecondsConversion
- Inherits:
-
UnixTimeConversion
- Object
- Conversion
- UnixTimeConversion
- Cosmos::UnixTimeSecondsConversion
- Defined in:
- lib/cosmos/conversions/unix_time_seconds_conversion.rb
Overview
Converts a unix format time: Epoch Jan 1 1970, seconds and microseconds, into a floating point number.
Instance Attribute Summary
Attributes inherited from Conversion
#converted_bit_size, #converted_type
Instance Method Summary collapse
-
#call(value, packet, buffer) ⇒ Float
Packet time in seconds since UNIX epoch.
-
#initialize(seconds_item_name, microseconds_item_name = nil) ⇒ UnixTimeSecondsConversion
constructor
Initializes converted_type to :FLOAT and converted_bit_size to 64.
-
#to_s ⇒ String
The name of the class followed by the time conversion.
Constructor Details
#initialize(seconds_item_name, microseconds_item_name = nil) ⇒ UnixTimeSecondsConversion
Initializes converted_type to :FLOAT and converted_bit_size to 64
25 26 27 28 29 |
# File 'lib/cosmos/conversions/unix_time_seconds_conversion.rb', line 25 def initialize(seconds_item_name, microseconds_item_name = nil) super(seconds_item_name, microseconds_item_name) @converted_type = :FLOAT @converted_bit_size = 64 end |
Instance Method Details
#call(value, packet, buffer) ⇒ Float
Returns Packet time in seconds since UNIX epoch.
33 34 35 |
# File 'lib/cosmos/conversions/unix_time_seconds_conversion.rb', line 33 def call(value, packet, buffer) super.to_f end |
#to_s ⇒ String
Returns The name of the class followed by the time conversion.
38 39 40 |
# File 'lib/cosmos/conversions/unix_time_seconds_conversion.rb', line 38 def to_s super << ".to_f" end |