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
-
#as_json
Returns a hash, that will be turned into a
::JSON
object and represent this object. -
#to_json(*args)
Stores class name (Complex) along with real value
r
and imaginary valuei
as::JSON
string.
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 10
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(*args)
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 25
def to_json(*args) as_json.to_json(*args) end