Class: TJSON::DataType::Float

Inherits:
Scalar show all
Defined in:
lib/tjson/datatype/float.rb

Overview

Floating point type

Constant Summary

Constants inherited from TJSON::DataType

TAGS

Instance Method Summary collapse

Methods inherited from Scalar

#inspect

Methods inherited from TJSON::DataType

[], encode, identify_type, parse

Instance Method Details

#decode(float) ⇒ Object

Raises:



11
12
13
14
# File 'lib/tjson/datatype/float.rb', line 11

def decode(float)
  raise TJSON::TypeError, "not a floating point value: #{float.inspect}" unless float.is_a?(::Numeric)
  float.to_f
end

#encode(float) ⇒ Object



16
17
18
# File 'lib/tjson/datatype/float.rb', line 16

def encode(float)
  float.to_f
end

#tagObject



7
8
9
# File 'lib/tjson/datatype/float.rb', line 7

def tag
  "f"
end