Class: CSVConverter::Converters::FloatConverter
- Inherits:
-
BaseConverter
- Object
- BaseConverter
- CSVConverter::Converters::FloatConverter
- Defined in:
- lib/csv_converter/converters/float_converter.rb
Overview
Converts a string into a float
Instance Attribute Summary
Attributes inherited from BaseConverter
Instance Method Summary collapse
-
#call ⇒ Float
Converts data into a Float.
-
#call! ⇒ Float
Converts data into a Float.
Methods inherited from BaseConverter
#data, #empty_value?, #initialize
Constructor Details
This class inherits a constructor from CSVConverter::Converters::BaseConverter
Instance Method Details
#call ⇒ Float
Converts data into a Float. If the decimal separator is a comma it is replaced by a period before parsing.
10 11 12 13 14 |
# File 'lib/csv_converter/converters/float_converter.rb', line 10 def call call! rescue CSVConverter::Error nullable_object end |
#call! ⇒ Float
Converts data into a Float. If the decimal separator is a comma it is replaced by a period before parsing.
19 20 21 22 23 |
# File 'lib/csv_converter/converters/float_converter.rb', line 19 def call! Float(data.sub(',', '.')) rescue StandardError => e raise CSVConverter::Error.new(e., ) end |