Class: OpenC3::JsonRpcSuccessResponse

Inherits:
JsonRpcResponse show all
Defined in:
lib/openc3/io/json_rpc.rb

Overview

Represents a JSON Remote Procedure Call Success Response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from JsonRpcResponse

from_json

Methods inherited from JsonRpc

#<=>, #as_json, #to_json

Constructor Details

#initialize(result, id) ⇒ JsonRpcSuccessResponse

Returns a new instance of JsonRpcSuccessResponse.

Parameters:

  • id (Integer)

    The identifier which will be matched to the request



335
336
337
338
# File 'lib/openc3/io/json_rpc.rb', line 335

def initialize(result, id)
  super(id)
  @hash['result'.freeze] = result
end

Class Method Details

.from_hash(hash) ⇒ JsonRpcSuccessResponse

Creates a JsonRpcSuccessResponse object from a Hash

Parameters:

  • hash (Hash)

    Hash containing the following keys: result and id

Returns:



349
350
351
# File 'lib/openc3/io/json_rpc.rb', line 349

def self.from_hash(hash)
  self.new(hash['result'.freeze], hash['id'.freeze])
end

Instance Method Details

#resultObject

Returns The result of the method request.

Returns:

  • (Object)

    The result of the method request



341
342
343
# File 'lib/openc3/io/json_rpc.rb', line 341

def result
  @hash['result'.freeze]
end