Class: OpenC3::JsonRpc
- 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
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#as_json(*a) ⇒ Hash
Hash representing the object.
-
#initialize ⇒ JsonRpc
constructor
A new instance of JsonRpc.
-
#to_json(*a) ⇒ String
The JSON encoded String.
Constructor Details
#initialize ⇒ JsonRpc
Returns a new instance of JsonRpc.
187 188 189 |
# File 'lib/openc3/io/json_rpc.rb', line 187 def initialize @hash = {} end |
Instance Method Details
#<=>(other) ⇒ Object
192 193 194 195 196 |
# File 'lib/openc3/io/json_rpc.rb', line 192 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
Returns Hash representing the object.
200 201 202 |
# File 'lib/openc3/io/json_rpc.rb', line 200 def as_json(*a) @hash.as_json(*a) end |
#to_json(*a) ⇒ String
Returns The JSON encoded String.
206 207 208 |
# File 'lib/openc3/io/json_rpc.rb', line 206 def to_json(*a) as_json(*a).to_json(*a) end |