Class: ROC::Float
- Includes:
- Types::ScalarType
- Defined in:
- lib/roc/objects/float.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #deserialize(val) ⇒ Object
-
#serialize(val) ⇒ Object
implementing scalar type required methods ##.
- #to_float ⇒ Object (also: #to_f)
Methods included from Types::ScalarType
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
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_float ⇒ Object Also known as: to_f
8 9 10 |
# File 'lib/roc/objects/float.rb', line 8 def to_float self.value.to_f end |