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



182
183
184
# File 'lib/openc3/io/json_rpc.rb', line 182

def initialize
  @hash = {}
end

Instance Method Details

#<=>(other) ⇒ Object



187
188
189
190
191
# File 'lib/openc3/io/json_rpc.rb', line 187

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

  self.as_json(:allow_nan => true) <=> other.as_json(:allow_nan => true)
end

#as_json(*a) ⇒ Hash



195
196
197
# File 'lib/openc3/io/json_rpc.rb', line 195

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

#to_json(*a) ⇒ String



201
202
203
# File 'lib/openc3/io/json_rpc.rb', line 201

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