module JSON::Pure::Generator::GeneratorMethods::Float - JSON implemention for Ruby

# module JSON::Pure::Generator::GeneratorMethods::Float

### Public Instance Methods

to_json(state = nil, *) click to toggle source

Returns a JSON string representation for this Float number.

    # File lib/json/pure/generator.rb, line 418
    def to_json(state = nil, *)
      state = State.from_state(state)
      case
      when infinite?
        if state.allow_nan?
          to_s
        else
          raise GeneratorError, "#{self} not allowed in JSON"
        end
      when nan?
        if state.allow_nan?
          to_s
        else
          raise GeneratorError, "#{self} not allowed in JSON"
        end
      else
        to_s
      end
    end