lib/ig_markets/format.rb
# Returns a formatted string for the specified currency amount and currency. Two decimal places are used for all
# currencies except the Japanese Yen.
#
# @param [Float, Integer] amount The currency amount to format.
# @param [String] currency_name The name or symbol of the currency.
#
# @return [String] The formatted currency amount, e.g. `"USD -130.40"`, `"AUD 539.10"`, `"JPY 3560"`.
Returns a formatted string for the specified currency amount and currency. Two decimal places are used for all
currencies except the Japanese Yen.
Returns a formatted string for the specified currency amount and currency . Two decimal places are used for all currencies except the Japanese Yen .
def currency(amount, currency_name)
      return '' unless amount
      if ['JPY', '¥'].include? currency_name
        "#{currency_name} #{format '%i', amount.to_i}"
      else
        "#{currency_name} #{format '%.2f', amount.to_f}"
      end
    end
def currency ( amount , currency_name ) return '' unless amount if [ 'JPY' , '¥'] . i nclude?  urrency_name "#{currency_name} #{format '%i', amount.to_i}" else "#{currency_name} #{format '%.2f', amount.to_f}" end end
Returns a formatted string for the specified currency amount and currency.
Returns a formatted string for the specified currency amount and currency .
The formatted currency amount, e.g.
The formatted currency amount e . g .
String
amount
currency_name
currency_name The name or symbol of the currency.
currency_name The name or symbol of the currency .