Module: Fiveruns::JSON::Pure::Generator::GeneratorMethods::Float

Defined in:
lib/fiveruns/json/generator.rb

Instance Method Summary collapse

Instance Method Details

#to_fjson(state = nil) ⇒ Object

Returns a FiverunsJSON string representation for this Float number.



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/fiveruns/json/generator.rb', line 316

def to_fjson(state = nil, *)
  case
  when infinite?
    if !state || state.allow_nan?
      to_s
    else
      raise GeneratorError, "#{self} not allowed in FiverunsJSON"
    end
  when nan?
    if !state || state.allow_nan?
      to_s
    else
      raise GeneratorError, "#{self} not allowed in FiverunsJSON"
    end
  else
    to_s
  end
end