Module: Codecs::FloatCodec

Defined in:
lib/emery/codecs.rb

Class Method Summary collapse

Class Method Details

.applicable?(type) ⇒ Boolean

Returns:



129
130
131
# File 'lib/emery/codecs.rb', line 129

def self.applicable?(type)
  type == Float
end

.deserialize(type, json_value) ⇒ Object



132
133
134
135
# File 'lib/emery/codecs.rb', line 132

def self.deserialize(type, json_value)
  T.check(T.union(Float, Integer), json_value)
  json_value.to_f
end

.serialize(type, value) ⇒ Object



136
137
138
# File 'lib/emery/codecs.rb', line 136

def self.serialize(type, value)
  T.check(Float, value)
end