Class: Gorillib::Factory::GraciousFloatFactory
- Inherits:
-
FloatFactory
- Object
- BaseFactory
- ConvertingFactory
- FloatFactory
- Gorillib::Factory::GraciousFloatFactory
- Defined in:
- lib/gorillib/factories.rb
Overview
Returns arg converted to a float.
- Numeric types are converted directly
- Strings can have ',' (which are removed) or end in
/LlFf/
(pig format); they should other conform to numeric representation or an error is raised. (this 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.
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
399 400 401 402 |
# File 'lib/gorillib/factories.rb', line 399 def convert(obj) if String === obj then obj = obj.to_s.tr(FLT_CRUFT_CHARS,'') ; end super(obj) end |