1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-30 19:22:21 +00:00

Fixed win percentage

This commit is contained in:
2015-02-06 10:44:04 -05:00
parent ffebffab55
commit 5c015ba2d8

View File

@@ -30,12 +30,17 @@ class Wrestler < ActiveRecord::Base
end
def seasonWinPercentage
if self.season_win > 0 and self.season_loss > 0
@percentage = self.season_win / (self.season_win + self.season_loss)
return @percentage
@win = self.season_win.to_f
@loss = self.season_loss.to_f
if @win > 0 and @loss != nil
@matchTotal = @win + @loss
@percentageDec = @win / @matchTotal
@percentage = @percentageDec * 100
return @percentage.to_i
elsif self.season_win == 0
return 0
elsif self.season_win == nil or self.season_loss == nil
return 0
end
end