Class: TJSON::DataType::Float

Inherits:
Number 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, #scalar?

Methods inherited from TJSON::DataType

[], generate, identify_type, parse

Instance Method Details

#convert(float) ⇒ Object

Raises:



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

def convert(float)
  raise TJSON::TypeError, "expected Float, got #{float.class}" unless float.is_a?(::Numeric)
  float.to_f
end

#generate(float) ⇒ Object



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

def generate(float)
  float.to_f
end

#tagObject



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

def tag
  "f"
end