Class: OpenC3::IpReadConversion
- Inherits:
-
Conversion
- Object
- Conversion
- OpenC3::IpReadConversion
- Defined in:
- lib/openc3/conversions/ip_read_conversion.rb
Instance Attribute Summary
Attributes inherited from Conversion
#converted_array_size, #converted_bit_size, #converted_type, #params
Instance Method Summary collapse
-
#call(value, _packet, _buffer) ⇒ Object
Perform the conversion on the value.
-
#initialize ⇒ IpReadConversion
constructor
A new instance of IpReadConversion.
-
#to_config(read_or_write) ⇒ String
Config fragment for this conversion.
-
#to_s ⇒ String
The conversion class.
Methods inherited from Conversion
Constructor Details
#initialize ⇒ IpReadConversion
Returns a new instance of IpReadConversion.
18 19 20 21 22 |
# File 'lib/openc3/conversions/ip_read_conversion.rb', line 18 def initialize @converted_type = :STRING @converted_bit_size = 120 @converted_array_size = nil end |
Instance Method Details
#call(value, _packet, _buffer) ⇒ Object
Perform the conversion on the value.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/openc3/conversions/ip_read_conversion.rb', line 32 def call(value, _packet, _buffer) byte4 = (value & 0xFF) value = value >> 8 byte3 = (value & 0xFF) value = value >> 8 byte2 = (value & 0xFF) value = value >> 8 byte1 = (value & 0xFF) return "#{byte1}.#{byte2}.#{byte3}.#{byte4}" end |
#to_config(read_or_write) ⇒ String
Returns Config fragment for this conversion.
50 51 52 |
# File 'lib/openc3/conversions/ip_read_conversion.rb', line 50 def to_config(read_or_write) " #{read_or_write}_CONVERSION #{self.class.name.class_name_to_filename}\n" end |
#to_s ⇒ String
Returns The conversion class.
44 45 46 |
# File 'lib/openc3/conversions/ip_read_conversion.rb', line 44 def to_s "#{self.class.to_s.split('::')[-1]}.new" end |