class CSVConverter::Converters::BigDecimalConverter
Converts a string into a decimal number
Public Instance Methods
call()
click to toggle source
Converts data into a BigDecimal. If the decimal separator is a comma it is replaced by a period before parsing. @return [BigDecimal] if an error occurs during conversion nil is returned.
# File lib/csv_converter/converters/big_decimal_converter.rb, line 12 def call call! rescue CSVConverter::Error nullable_object end
call!()
click to toggle source
Converts data into a BigDecimal. If the decimal separator is a comma it is replaced by a period before parsing. @return [BigDecimal] if an error occurs during conversion an error is raised.
# File lib/csv_converter/converters/big_decimal_converter.rb, line 21 def call! BigDecimal(data.sub(',', '.')) rescue StandardError => e raise CSVConverter::Error.new(e.message, options) end
Private Instance Methods
nullable_object()
click to toggle source
# File lib/csv_converter/converters/big_decimal_converter.rb, line 29 def nullable_object nil end