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