deck 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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(rank = 'Joker', suit = 'None')
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 = 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
 
@@ -1,6 +1,3 @@
1
-
2
-
3
-
4
1
  class Game
5
2
 
6
3
  attr_reader :deck, :hands, :number_of_hands, :number_of_cards
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  class Hand < Deck
4
2
 
5
3
  def initialize(options = {})
@@ -1,3 +1,3 @@
1
1
  class Deck
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -49,5 +49,12 @@ class CardTest < Test::Unit::TestCase
49
49
  assert card > card2
50
50
  end
51
51
 
52
+ def test_can_increase_card
53
+ card = Card.new(10, "h")
54
+ card+= 1
55
+ assert_equal "Jack of Hearts", card.to_s
56
+ end
57
+
58
+
52
59
 
53
60
  end
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.0
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-05 00:00:00.000000000 +01:00
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