Class: OpenC3::JsonRpc

Inherits:
Object show all
Includes:
Comparable
Defined in:
lib/openc3/io/json_rpc.rb

Overview

Base class for all JSON Remote Procedure Calls. Provides basic comparison and Hash to JSON conversions.

Direct Known Subclasses

JsonRpcError, JsonRpcRequest, JsonRpcResponse

Instance Method Summary collapse

Constructor Details

#initializeJsonRpc



198
199
200
# File 'lib/openc3/io/json_rpc.rb', line 198

def initialize
  @hash = {}
end

Instance Method Details

#<=>(other) ⇒ Object



203
204
205
206
207
# File 'lib/openc3/io/json_rpc.rb', line 203

def <=>(other)
  return nil unless other.respond_to?(:as_json)

  self.as_json() <=> other.as_json()
end

#as_json(*a) ⇒ Hash



211
212
213
# File 'lib/openc3/io/json_rpc.rb', line 211

def as_json(*a)
  @hash.as_json(*a)
end

#to_json(*a) ⇒ String



217
218
219
# File 'lib/openc3/io/json_rpc.rb', line 217

def to_json(*a)
  as_json(*a).to_json(*a)
end