Class: Complex
Relationships & Source Files | |
Inherits: | Object |
Defined in: | ext/json/lib/json/add/complex.rb |
Class Method Summary
-
.json_create(object)
Deserializes JSON string by converting Real value
r
, imaginary valuei
, to aComplex
object.
Instance Method Summary
Class Method Details
.json_create(object)
Deserializes JSON string by converting Real value r
, imaginary value i
, to a Complex
object.
# File 'ext/json/lib/json/add/complex.rb', line 11
def self.json_create(object) Complex(object['r'], object['i']) end
Instance Method Details
#as_json
Returns a hash, that will be turned into a ::JSON
object and represent this object.
#to_json
Stores class name (Complex) along with real value r
and imaginary value i
as ::JSON
string
# File 'ext/json/lib/json/add/complex.rb', line 26
def to_json(*) as_json.to_json end