lib/exchange/iso.rb in exchange-1.2.0 vs lib/exchange/iso.rb in exchange-1.2.1

- old
+ new

@@ -19,11 +19,11 @@ private # @private # @macro [attach] install_operations - def install_operation op + def install_operation op self.class_eval <<-EOV def #{op} amount, currency, precision=nil, opts={} minor = definitions[currency][:minor_unit] money = amount.is_a?(BigDecimal) ? amount : BigDecimal.new(amount.to_s, precision_for(amount, currency)) if opts[:psych] && minor > 0 @@ -109,11 +109,11 @@ # @example Convert a currency with a three decimal minor to a string # Exchange::ISO.stringif(34.34, :omr) #=> "OMR 34.340" # @example Convert a currency to a string without the currency # Exchange::ISO.stringif(34.34, :omr, :amount_only => true) #=> "34.340" # - def stringify amount, currency, opts={} + def stringify amount, currency, opts={} definition = definitions[currency] separators = definition[:separators] || {} format = "%.#{definition[:minor_unit]}f" string = format % amount major, minor = string.split('.') @@ -128,11 +128,11 @@ # Returns the symbol for a given currency. Returns nil if no symbol is present # @param currency The currency to return the symbol for # @return [String, NilClass] The symbol or nil # - def symbol currency + def symbol currency definitions[currency][:symbol] end # Use this to round a currency amount. This allows us to round exactly to the number of minors the currency has in the # iso definition @@ -170,11 +170,11 @@ # symbolizes keys and returns a new hash # def symbolize_keys hsh new_hsh = Hash.new - hsh.each_pair do |k,v| - v = symbolize_keys v if v.is_a?(Hash) + hsh.each_pair do |k,v| + v = symbolize_keys v if v.is_a?(Hash) new_hsh[k.downcase.to_sym] = v end new_hsh end