Class: Cosmos::ProcessorConversion
- Inherits:
-
Conversion
- Object
- Conversion
- Cosmos::ProcessorConversion
- Defined in:
- lib/cosmos/conversions/processor_conversion.rb
Overview
Retrieves the result from an item processor
Instance Attribute Summary
Attributes inherited from Conversion
#converted_bit_size, #converted_type
Instance Method Summary collapse
-
#call(value, packet, buffer) ⇒ Varies
The result of the associated processor.
-
#initialize(processor_name, result_name, converted_type = nil, converted_bit_size = nil) ⇒ ProcessorConversion
constructor
A new instance of ProcessorConversion.
-
#to_s ⇒ String
The type of processor.
Constructor Details
#initialize(processor_name, result_name, converted_type = nil, converted_bit_size = nil) ⇒ ProcessorConversion
Returns a new instance of ProcessorConversion.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cosmos/conversions/processor_conversion.rb', line 22 def initialize(processor_name, result_name, converted_type = nil, converted_bit_size = nil) super() @processor_name = processor_name.to_s.upcase @result_name = result_name.to_s.upcase.intern if ConfigParser.handle_nil(converted_type) @converted_type = converted_type.to_s.upcase.intern raise ArgumentError, "Unknown converted type: #{converted_type}" if !BinaryAccessor::DATA_TYPES.include?(@converted_type) end @converted_bit_size = Integer(converted_bit_size) if ConfigParser.handle_nil(converted_bit_size) end |
Instance Method Details
#call(value, packet, buffer) ⇒ Varies
Returns The result of the associated processor.
35 36 37 |
# File 'lib/cosmos/conversions/processor_conversion.rb', line 35 def call(value, packet, buffer) packet.processors[@processor_name].results[@result_name] || 0 # Never return nil end |
#to_s ⇒ String
Returns The type of processor.
40 41 42 |
# File 'lib/cosmos/conversions/processor_conversion.rb', line 40 def to_s "ProcessorConversion #{@processor_name} #{@result_name}" end |