lib/ig_markets/format.rb
# Returns a formatted string for the specified currency amount and currency, and colors it red for negative values
# and green for positive values. 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 currency.
#
# @return [String] The formatted and colored currency amount, e.g. `"USD -130.40"`, `"AUD 539.10"`, `"JPY 3560"`.
Returns a formatted string for the specified currency amount and currency, and colors it red for negative values
and green for positive values. Two decimal places are used for all currencies except the Japanese Yen.
Returns a formatted string for the specified currency amount and currency and colors it red for negative values and green for positive values . Two decimal places are used for all currencies except the Japanese Yen .
def colored_currency(amount, currency_name)
      return '' unless amount
      color = amount.negative? ? :red : :green
      ColorizedString[currency(amount, currency_name)].colorize color
    end
def colored_currency ( amount , currency_name ) return '' unless amount color = amount . negative? ? :red : :green ColorizedString [ currency ( amount , currency_name ) ] . colorize color end
Returns a formatted string for the specified currency amount and currency, and colors it red for negative values
and green for positive values.
Returns a formatted string for the specified currency amount and currency and colors it red for negative values and green for positive values .
The formatted and colored currency amount, e.g.
The formatted and colored currency amount e . g .
String
amount
currency_name
currency_name The currency.
currency_name The currency .