From 1bef8fc74e78da01ea20bfe906ef8c6d158f1d1a Mon Sep 17 00:00:00 2001 From: Charley DAVID Date: Fri, 26 May 2017 10:42:58 -0300 Subject: [PATCH] Format mixed cureencies outputs --- app/controllers/application_controller.rb | 2 +- app/controllers/prices_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7b0f42e..bedd829 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -11,7 +11,7 @@ def best_deals all_games.each do |_code, games| lowest = games.flat_map(&:prices).min_by { |price| price.value.exchange_to('USD') } next if lowest.blank? - rates = currencies.map { |c| lowest.value.exchange_to(c) } + rates = currencies.map { |c| lowest.value.exchange_to(c).format } rows << [game.first.title, ISO3166::Country[lowest.country].translation('en')].concat(rates) end end diff --git a/app/controllers/prices_controller.rb b/app/controllers/prices_controller.rb index b82d6a9..355c5e5 100644 --- a/app/controllers/prices_controller.rb +++ b/app/controllers/prices_controller.rb @@ -22,8 +22,8 @@ def render_csv prices = games.flat_map(&:prices) csv << [games.first.title] + @countries.map do |country| price = prices.detect { |p| p.country == country } - next 'NA' unless price - @currency ? price.value.exchange_to(@currency) : price.value + next 'N/A' unless price + @currency ? price.value.exchange_to(@currency) : price.value.format end end end