Module: JSON::Pure::Generator::GeneratorMethods::Float
- Defined in:
- lib/crazy_ivan/vendor/json-1.1.7/lib/json/pure/generator.rb
Instance Method Summary collapse
-
#to_json(state = nil) ⇒ Object
Returns a JSON string representation for this Float number.
Instance Method Details
#to_json(state = nil) ⇒ Object
Returns a JSON string representation for this Float number.
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/crazy_ivan/vendor/json-1.1.7/lib/json/pure/generator.rb', line 352 def to_json(state = nil, *) case when infinite? if !state || state.allow_nan? to_s else raise GeneratorError, "#{self} not allowed in JSON" end when nan? if !state || state.allow_nan? to_s else raise GeneratorError, "#{self} not allowed in JSON" end else to_s end end |