Method: OpenC3::GenericConversion#initialize

Defined in:
lib/openc3/conversions/generic_conversion.rb

#initialize(code_to_eval, converted_type = nil, converted_bit_size = nil, converted_array_size = nil) ⇒ GenericConversion

Returns a new instance of GenericConversion.

Parameters:

  • code_to_eval (String)

    The Ruby code to evaluate which should return the converted value

  • converted_type (Symbol) (defaults to: nil)

    The converted data type. Must be one of BinaryAccessor::DATA_TYPES

  • converted_bit_size (Integer) (defaults to: nil)

    The size in bits of the converted value

  • converted_array_size (Integer) (defaults to: nil)

    The size in bits of the converted array value (full size of all items if array)



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/openc3/conversions/generic_conversion.rb', line 41

def initialize(code_to_eval, converted_type = nil, converted_bit_size = nil, converted_array_size = nil)
  super()
  @code_to_eval = code_to_eval
  if ConfigParser.handle_nil(converted_type)
    converted_type = converted_type.to_s.upcase.intern
    raise "Invalid type #{converted_type}" unless BinaryAccessor::DATA_TYPES.include?(converted_type)

    @converted_type = converted_type
  end
  @converted_bit_size = Integer(converted_bit_size) if ConfigParser.handle_nil(converted_bit_size)
  @converted_array_size = Integer(converted_array_size) if ConfigParser.handle_nil(converted_array_size)
  @params = [@code_to_eval, @converted_type, @converted_bit_size, @converted_array_size]
end