deck-of-cards 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/deck-of-cards/card.rb +11 -1
- data/lib/deck-of-cards/version.rb +1 -1
- metadata +1 -1
data/lib/deck-of-cards/card.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
-
Card
|
1
|
+
class Card
|
2
2
|
include Comparable
|
3
|
+
|
4
|
+
attr_reader :rank, :suit
|
5
|
+
|
6
|
+
def initialize rank, suit
|
7
|
+
@rank, @suit = rank, suit
|
8
|
+
end
|
3
9
|
|
4
10
|
def <=> other_card
|
5
11
|
self.value <=> other_card.value
|
@@ -23,4 +29,8 @@ Card = Struct.new :rank, :suit do
|
|
23
29
|
def to_s
|
24
30
|
"#{rank} of #{suit}"
|
25
31
|
end
|
32
|
+
|
33
|
+
def inspect
|
34
|
+
"<#{rank} of #{suit}>"
|
35
|
+
end
|
26
36
|
end
|