lib/brcobranca/currency.rb in brcobranca-6.9.1 vs lib/brcobranca/currency.rb in brcobranca-7.0.0

- old
+ new

@@ -1,18 +1,19 @@ # -*- encoding: utf-8 -*- +# # @author Fernando Vieira do http://simplesideias.com.br module Brcobranca #:nodoc:[all] module Currency #:nodoc:[all] # ImplementaĆ§Ć£o feita por Fernando Vieira do http://simplesideias.com.br # post http://simplesideias.com.br/usando-number_to_currency-em-modelos-no-rails - BRL = { delimiter: '.', separator: ',', unit: 'R$', precision: 2, position: 'before' } - USD = { delimiter: ',', separator: '.', unit: 'US$', precision: 2, position: 'before' } + BRL = { delimiter: '.', separator: ',', unit: 'R$', precision: 2, position: 'before' }.freeze + USD = { delimiter: ',', separator: '.', unit: 'US$', precision: 2, position: 'before' }.freeze DEFAULT = BRL.merge(unit: '') module String #:nodoc:[all] def to_number(_options = {}) - return gsub(/,/, '.').to_f if self.numeric? + return tr(',', '.').to_f if numeric? nil end def numeric? self =~ /^(\+|-)?[0-9]+((\.|,)[0-9]+)?$/ ? true : false