lib/convertator/converter.rb in convertator-0.3.0 vs lib/convertator/converter.rb in convertator-0.3.1
- old
+ new
@@ -1,12 +1,16 @@
require 'bigdecimal'
require 'bigdecimal/util'
+require 'convertator/utils'
+require 'convertator/middleware'
module Convertator
class Converter
class UnknownCurrencyError < StandardError; end
+ include Convertator::Utils
+
attr_reader :provider
def initialize(provider = :cbr, accuracy = 10)
@provider = load_provider(provider)
@accuracy = accuracy
@@ -53,19 +57,9 @@
convert_s(amount, currency_from, currency_to)
end
end
private
-
- def symbolize_keys(array)
- array.each_with_object({}) do |(k, v), memo|
- memo[normalize_currency(k)] = v
- end
- end
-
- def normalize_currency(currency)
- currency.to_sym.upcase
- end
def round(value)
BigDecimal.save_rounding_mode do
BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up)
value.round(@accuracy)