deck 1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/deck/card.rb +24 -5
- data/lib/deck/game.rb +0 -3
- data/lib/deck/hand.rb +0 -2
- data/lib/deck/version.rb +1 -1
- data/test/card_test.rb +7 -0
- metadata +2 -2
data/lib/deck/card.rb
CHANGED
@@ -1,14 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
class Card
|
4
2
|
|
5
3
|
include Enumerable
|
6
4
|
|
7
5
|
attr_reader :suit, :rank
|
8
6
|
|
9
|
-
def initialize(
|
7
|
+
def initialize(ran = 'Joker', suit = 'None')
|
8
|
+
#TODO clean this up
|
9
|
+
ran = "Jack" if ran == 11
|
10
|
+
ran = "Queen" if ran == 12
|
11
|
+
ran = "King" if ran == 13
|
12
|
+
ran = "Ace" if ran == 14
|
13
|
+
suit = "Hearts" if suit == "H"
|
14
|
+
suit = "Clubs" if suit == "C"
|
15
|
+
suit = "Spades" if suit == "S"
|
16
|
+
suit = "Diamonds" if suit == "D"
|
10
17
|
@suit = suit
|
11
|
-
@rank =
|
18
|
+
@rank = ran
|
12
19
|
end
|
13
20
|
|
14
21
|
|
@@ -31,6 +38,15 @@ class Card
|
|
31
38
|
@suit.capitalize
|
32
39
|
end
|
33
40
|
|
41
|
+
def + (num)
|
42
|
+
Card.new(rank.to_i + num.to_i, suit)
|
43
|
+
end
|
44
|
+
|
45
|
+
def - (num)
|
46
|
+
Card.new(rank.to_i - num.to_i, suit)
|
47
|
+
end
|
48
|
+
|
49
|
+
|
34
50
|
def to_s
|
35
51
|
"#{rank} of #{suit}"
|
36
52
|
end
|
@@ -69,7 +85,10 @@ class Card
|
|
69
85
|
15
|
70
86
|
else @rank.to_i
|
71
87
|
end
|
72
|
-
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
|
73
92
|
|
74
93
|
end
|
75
94
|
|
data/lib/deck/game.rb
CHANGED
data/lib/deck/hand.rb
CHANGED
data/lib/deck/version.rb
CHANGED
data/test/card_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-11 00:00:00.000000000 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
description: represent playing cards, hands, decks and games
|