Module: PSON::Pure::Generator::GeneratorMethods::Float

Defined in:
lib/vendor/puppet/external/pson/pure/generator.rb

Instance Method Summary collapse

Instance Method Details

#to_pson(state = nil) ⇒ Object

Returns a PSON string representation for this Float number.



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/vendor/puppet/external/pson/pure/generator.rb', line 323

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