Color momey

This commit is contained in:
Andrew Tomaka 2015-04-25 13:12:28 -04:00
parent 1dc14ac245
commit cfce9d80ab
2 changed files with 6 additions and 2 deletions

6
app.rb
View file

@ -66,6 +66,10 @@ def players
}
end
def money_style(value)
value.to_f < 0 ? 'color:#a94442' : 'color:#3c763d'
end
def readable_number(value)
if value.to_f < 0
negative = true
@ -83,7 +87,7 @@ def readable_number(value)
end
value = 0.0 unless value
return sprintf('%.2f', value) + "_"
return sprintf('%.2f', value) + "&nbsp;"
end
def numbers

View file

@ -15,7 +15,7 @@
<td style="<%= player_style(raid.attacker) %>"><%= raid.attacker %></td>
<td style="<%= player_style(raid.defender) %>"><%= raid.defender %></td>
<td class="text-right"><%= readable_number(raid.soldiers) %></td>
<td class="text-right"><%= readable_number(raid.money) %></td>
<td class="text-right" style="<%=money_style(raid.money)%>"><%= readable_number(raid.money) %></td>
<td class="text-right"><%= raid.created_at.strftime('%H:%M on %m-%d-%Y') %></td>
</tr>
<% end %>