Class: Float
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.json_create(object) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/cosmos/io/json_rpc.rb', line 74 def self.json_create(object) case object['raw'] when "Infinity" then Float::INFINITY when "-Infinity" then -Float::INFINITY when "NaN" then Float::NAN end end |
Instance Method Details
#as_json(options = nil) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/cosmos/io/json_rpc.rb', line 82 def as_json( = nil) return { "json_class" => Float, "raw" => "Infinity" } if self.infinite? == 1 return { "json_class" => Float, "raw" => "-Infinity" } if self.infinite? == -1 return { "json_class" => Float, "raw" => "NaN" } if self.nan? return self end |