better formatting of money
This commit is contained in:
parent
a01cd54e6a
commit
ea5c8acc68
2 changed files with 6 additions and 5 deletions
5
app.rb
5
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 + '<strong>' + symbol + '</strong>'
|
||||
return sprintf('%.2f', value.to_f / number.to_f) + '<strong>' + symbol + '</strong>'
|
||||
end
|
||||
end
|
||||
|
||||
return value
|
||||
value = 0.0 unless value
|
||||
return sprintf('%.2f', value) + "_"
|
||||
end
|
||||
|
||||
def numbers
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<h2>Index</h2>
|
||||
|
||||
<table class="table table-striped">
|
||||
<table class="table table-striped table-hover table-bordered table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Attacker</td>
|
||||
|
@ -15,8 +15,8 @@
|
|||
<tr>
|
||||
<td><%= raid.attacker %></td>
|
||||
<td><%= raid.defender %></td>
|
||||
<td><%= readable_number(raid.soldiers) %></td>
|
||||
<td><%= readable_number(raid.money) %></td>
|
||||
<td class="text-right"><%= readable_number(raid.soldiers) %></td>
|
||||
<td class="text-right"><%= readable_number(raid.money) %></td>
|
||||
<td><%= raid.created_at %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in a new issue