Class: Gorillib::Factory::FloatFactory
- Inherits:
-
ConvertingFactory
- Object
- BaseFactory
- ConvertingFactory
- Gorillib::Factory::FloatFactory
- Defined in:
- lib/gorillib/factories.rb
Overview
Returns arg converted to a float.
- Numeric types are converted directly
- Strings strictly conform to numeric representation or an error is raised (which differs from the behavior of String#to_f)
- Strings in radix format (an exact hexadecimal encoding of a number) are properly interpreted.
- Octal is not interpreted! This means an IntegerFactory receiving '011' will get 9, a FloatFactory 11.0
- Other types are converted using obj.to_f.
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from ConvertingFactory
Methods inherited from BaseFactory
blankish?, #blankish?, #initialize, #native?, native?, #receive, typename, #typename
Constructor Details
This class inherits a constructor from Gorillib::Factory::BaseFactory
Instance Method Details
#convert(obj) ⇒ Object
369 |
# File 'lib/gorillib/factories.rb', line 369 def convert(obj) Float(obj) ; end |