Class: OpenC3::IpWriteConversion
- Inherits:
-
Conversion
- Object
- Conversion
- OpenC3::IpWriteConversion
- Defined in:
- lib/openc3/conversions/ip_write_conversion.rb
Instance Attribute Summary
Attributes inherited from Conversion
#converted_array_size, #converted_bit_size, #converted_type
Instance Method Summary collapse
-
#call(value, _packet, _buffer) ⇒ Object
Perform the conversion on the value.
-
#initialize ⇒ IpWriteConversion
constructor
A new instance of IpWriteConversion.
-
#to_config(read_or_write) ⇒ String
Config fragment for this conversion.
-
#to_s ⇒ String
The conversion class.
Methods inherited from Conversion
Constructor Details
#initialize ⇒ IpWriteConversion
Returns a new instance of IpWriteConversion.
23 24 25 26 27 |
# File 'lib/openc3/conversions/ip_write_conversion.rb', line 23 def initialize @converted_type = :UINT @converted_bit_size = 32 @converted_array_size = nil end |
Instance Method Details
#call(value, _packet, _buffer) ⇒ Object
Perform the conversion on the value.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/openc3/conversions/ip_write_conversion.rb', line 37 def call(value, _packet, _buffer) bytes = value.split('.') result = 0 result += Integer(bytes[0]) result = result << 8 result += Integer(bytes[1]) result = result << 8 result += Integer(bytes[2]) result = result << 8 result += Integer(bytes[3]) return result end |
#to_config(read_or_write) ⇒ String
Returns Config fragment for this conversion.
57 58 59 |
# File 'lib/openc3/conversions/ip_write_conversion.rb', line 57 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.
51 52 53 |
# File 'lib/openc3/conversions/ip_write_conversion.rb', line 51 def to_s "#{self.class.to_s.split('::')[-1]}.new" end |