Class: ROC::Float

Inherits:
Base
  • Object
show all
Includes:
Types::ScalarType
Defined in:
lib/roc/objects/float.rb

Instance Attribute Summary

Attributes inherited from Base

#key, #options

Instance Method Summary collapse

Methods included from Types::ScalarType

#clobber, #inspect, #setex

Methods included from Types::MethodGenerators

#deserializing_method, #nonserializing_method, #serializing_and_deserializing_method, #serializing_method, #zero_arg_method

Methods inherited from Base

#clobber, delegate_methods, #initialize, #method_missing, #respond_to?, #seed

Methods included from Types::AllTypes

#eval

Constructor Details

This class inherits a constructor from ROC::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ROC::Base

Instance Method Details

#deserialize(val) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/roc/objects/float.rb', line 19

def deserialize(val)
  if val.nil?
    nil
  elsif 'Infinity' == val
    1.0 / 0
  elsif '-Infinity' == val
    -1.0 / 0
  else
    val.to_f
  end
end

#serialize(val) ⇒ Object

implementing scalar type required methods ##



15
16
17
# File 'lib/roc/objects/float.rb', line 15

def serialize(val)
  val.to_s
end

#to_floatObject Also known as: to_f



8
9
10
# File 'lib/roc/objects/float.rb', line 8

def to_float
  self.value.to_f
end