C0 code coverage information
Generated on Thu Jun 07 11:33:59 -0400 2007 with rcov 0.8.0
Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
1 class Player < ActiveRecord::Base
2 belongs_to :team
3 belongs_to :tournament
4 has_many :player_results, :dependent => :destroy
5
6 def self.safely_sorted_by(meth = :points_per_20h)
7 return [] if PlayerResult.count == 0
8 players = self.players_who_have_played
9 players.sort! { |p, q|
10 a = p.send(meth) === Float
11 if a and p.send(meth).nan? and q.send(meth).nan?
12 0
13 elsif a and p.send(meth).nan?
14 -1
15 elsif a and q.send(meth).nan?
16 1
17 else
18 p.send(meth) <=> q.send(meth)
19 end
20 }
21
22 players
23 end
24
25 def self.players_who_have_played
26 find(:all).select {|p| p.player_results.size > 0}
27 end
28
29 def powers
30 out = 0
31 player_results.each do |k|
32 out += k.powers or 0
33 end
34 out
35 end
36
37 def tossups
38 out = 0
39 player_results.each do |k|
40 out += k.tossups
41 end
42 out
43 end
44 def negs
45 out = 0
46 player_results.each do |k|
47 out += k.negs
48 end
49 out
50 end
51
52 def powers_per_neg
53 if negs == 0
54 return (0.0/0.0)
55 else
56 return powers.to_f / negs.to_f
57 end
58 end
59
60 def points
61 powers * config.power +
62 tossups * config.tossup +
63 negs * config.neg
64 end
65
66 def tuh
67 out = 0
68 player_results.each do |k|
69 out += k.tuh
70 end
71 out
72 end
73
74 def games_played
75 out = 0
76 player_results.each do |k|
77 out += k.games_played
78 end
79 if out % 1 == 0
80 return out.to_i
81 else
82 out
83 end
84 end
85
86 def points_per_tuh
87 points.to_f / tuh.to_f
88 end
89
90 def points_per_20h
91 # Dumb fudge for fun
92 if points_per_tuh.nan? or points_per_tuh.infinite?
93 #return 0.0
94 end
95 points_per_tuh*20.0
96 end
97
98 def points_per_game
99 points.to_f / games_played
100 end
101 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.0.