Skip to content

Commit

Permalink
Format mixed cureencies outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Calyhre committed May 26, 2017
1 parent fbf8370 commit 1bef8fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/prices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1bef8fc

Please sign in to comment.