1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-31 19:45:45 +00:00

Calculated win percentage

This commit is contained in:
2015-02-06 10:31:47 -05:00
parent 5b8e90b50a
commit ffebffab55
4 changed files with 18 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
class Wrestler < ActiveRecord::Base
belongs_to :school
belongs_to :weight
attr_accessor :matches_all, :isWrestlingThisRound, :boutByRound
attr_accessor :matches_all, :isWrestlingThisRound, :boutByRound, :seasonWinPercentage
def isWrestlingThisRound(matchRound)
@gMatches = Match.where(g_id: self.id, round: matchRound)
@@ -29,4 +29,15 @@ class Wrestler < ActiveRecord::Base
return @gMatches + @rMatches
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
elsif self.season_win == 0
return 0
end
end
end