C0 code coverage information
Generated on Thu Dec 13 20:44:49 -0200 2007 with rcov 0.8.1.2
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.
| Name |
Total lines |
Lines of code |
Total coverage |
Code coverage |
|
lib/card.rb
|
31
|
25
|
|
|
1 CARDS = '23456789TJQKA'
2 SUITS = {'H' => :hearts, 'D' => :diamonds, 'S' => :spades, 'C' => :clubs}
3
4 class Card
5 include Comparable
6 attr_reader :rank, :suit
7
8 def initialize(str)
9 idx = CARDS.index(str[0,1])
10 @suit = SUITS[str[1,1]]
11 if idx.nil? or @suit.nil?
12 raise InvalidCard.new()
13 end
14 @rank = idx + 2
15 end
16
17 def <=>(other)
18 return @rank <=> other.rank
19 end
20
21 def eql?(other)
22 self == other
23 end
24
25 def hash
26 @rank.hash
27 end
28 end
29
30 class InvalidCard < Exception
31 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.