Class: TCellAgent::Rust::NativeAgentResponse
- Inherits:
-
Object
- Object
- TCellAgent::Rust::NativeAgentResponse
- Defined in:
- lib/tcell_agent/rust/native_agent_response.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(native_method_name, response, response_len) ⇒ NativeAgentResponse
constructor
A new instance of NativeAgentResponse.
Constructor Details
#initialize(native_method_name, response, response_len) ⇒ NativeAgentResponse
Returns a new instance of NativeAgentResponse.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tcell_agent/rust/native_agent_response.rb', line 6 def initialize(native_method_name, response, response_len) @response = {} @errors = [] if response_len < 0 @errors.push( "Error response from `#{native_method_name}` in native library method: #{response_len}" ) return end begin @response = JSON.parse(response.get_string(0, response_len)) if @response['error'] @errors.push( "#{native_method_name} returned an error: #{@response['error']}" ) @response = {} end if @response['errors'] @response['errors'].each do |error| @errors.push( "#{native_method_name} returned an error: #{error}" ) @response = {} end end rescue JSON::ParserError @errors.push( "Could not parse json response from `#{native_method_name}` in native library." ) @response = {} end end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
4 5 6 |
# File 'lib/tcell_agent/rust/native_agent_response.rb', line 4 def errors @errors end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/tcell_agent/rust/native_agent_response.rb', line 4 def response @response end |