Class: Cosmos::Conversion
- Defined in:
- lib/cosmos/conversions/conversion.rb
Overview
Performs a general conversion via the implementation of the call method
Direct Known Subclasses
GenericConversion, NewPacketLogConversion, ProcessorConversion, ReceivedCountConversion, ReceivedTimeFormattedConversion, ReceivedTimeSecondsConversion, SegmentedPolynomialConversion, UnixTimeConversion
Instance Attribute Summary collapse
-
#converted_bit_size ⇒ Integer
readonly
The size in bits of the converted value.
-
#converted_type ⇒ Symbol
readonly
The converted data type.
Instance Method Summary collapse
-
#call(value, packet, buffer) ⇒ Object
Perform the conversion on the value.
-
#initialize ⇒ Conversion
constructor
Create a new conversion.
-
#to_s ⇒ String
The conversion class.
Constructor Details
#initialize ⇒ Conversion
Create a new conversion
23 24 25 26 |
# File 'lib/cosmos/conversions/conversion.rb', line 23 def initialize @converted_type = nil @converted_bit_size = nil end |
Instance Attribute Details
#converted_bit_size ⇒ Integer (readonly)
Returns The size in bits of the converted value.
20 21 22 |
# File 'lib/cosmos/conversions/conversion.rb', line 20 def converted_bit_size @converted_bit_size end |
#converted_type ⇒ Symbol (readonly)
Returns The converted data type. Must be one of StructureItem#data_type.
18 19 20 |
# File 'lib/cosmos/conversions/conversion.rb', line 18 def converted_type @converted_type end |
Instance Method Details
#call(value, packet, buffer) ⇒ Object
Perform the conversion on the value.
36 37 38 |
# File 'lib/cosmos/conversions/conversion.rb', line 36 def call(value, packet, buffer) raise "call method must be defined by subclass" end |
#to_s ⇒ String
Returns The conversion class.
41 42 43 |
# File 'lib/cosmos/conversions/conversion.rb', line 41 def to_s self.class.to_s.split('::')[-1] end |