diff --git a/app.rb b/app.rb index 7a120f3..a3f3e08 100644 --- a/app.rb +++ b/app.rb @@ -29,11 +29,12 @@ end def readable_number(value) numbers.each do |number, symbol| if value.to_f / number.to_f > 1 - return (value.to_f / number.to_f).round(2).to_s + '' + symbol + '' + return sprintf('%.2f', value.to_f / number.to_f) + '' + symbol + '' end end - return value + value = 0.0 unless value + return sprintf('%.2f', value) + "_" end def numbers diff --git a/views/index.erb b/views/index.erb index 09222c6..7ea2b84 100644 --- a/views/index.erb +++ b/views/index.erb @@ -1,6 +1,6 @@

Index

- +
@@ -15,8 +15,8 @@ - - + + <% end %>
Attacker
<%= raid.attacker %> <%= raid.defender %><%= readable_number(raid.soldiers) %><%= readable_number(raid.money) %><%= readable_number(raid.soldiers) %><%= readable_number(raid.money) %> <%= raid.created_at %>