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



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

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:



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

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



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

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