Module: JSON::TruffleRuby::Generator::GeneratorMethods::Float
- Defined in:
- lib/json/truffle_ruby/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.
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
# File 'lib/json/truffle_ruby/generator.rb', line 534 def to_json(state = nil, *) state = State.from_state(state) case when infinite? if state.allow_nan? to_s else raise GeneratorError.new("#{self} not allowed in JSON", self) end when nan? if state.allow_nan? to_s else raise GeneratorError.new("#{self} not allowed in JSON", self) end else to_s end end |