fiftytwo 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c00da0e98ce49dd9546e2936caf0f8b19dea1353ff953e35edf0fa4e8856e97
4
- data.tar.gz: bd0ec3c7c3b7bb0305c3b9b8ed534865eee21dd47a9b0e61e69655d9a7d3c8ff
3
+ metadata.gz: f841300403b3e5e84bd2094a711ee89c13333537e3cabd08f3dfff000d59f69c
4
+ data.tar.gz: be8c200b6207437b4cabe5c500df1ff80caccf17ca8845a048c124c6ac86d97d
5
5
  SHA512:
6
- metadata.gz: c2dbb21639b82fe689c8de2ef7033783e9a5ade2fd35372f7e763b09464cec1bc46bac943cd9274499621143922fe7eb7c0d34426b9430f698ea8dcc120b3216
7
- data.tar.gz: cebde92a30ff69c21a3244e29588eef325431c0d684cddbb2b7a66c4bf34846a397b8529edc87397862512fbde75bd9a0960ff61c0f83d86e569211aecef6d83
6
+ metadata.gz: 579cf55130a79d92779edf40dce3f99e232270845c4f8a48097d1f904b759317f3aa19cba206e62bf60917306ac05b008b02cc938e21a4d017b5a97e529662b9
7
+ data.tar.gz: '0643844dd685e0f5c44f629f5db3c70b5599c00cfe136ba914448c88cf2974b864f7e30c6a661cb69a90544da82e65eff527b2eef7618f8a37191cef0f581c23'
data/README.md CHANGED
@@ -111,7 +111,7 @@ my_hand = FiftyTwo::Hand.new
111
111
  your_hand = FiftyTwo::Hand.new
112
112
  # => #<FiftyTwo::Hand:0x00007fb3d21c68c0 @cards=[]>
113
113
 
114
- deck.deal([my_hand, your_hand], hand_size: 5)
114
+ deck.deal([my_hand, your_hand], 5)
115
115
  "Deck has #{deck.count} cards, I have #{my_hand.count} cards, you have #{your_hand.count} cards"
116
116
  # => "Deck has 42 cards, I have 5 cards, you have 5 cards"
117
117
 
@@ -146,6 +146,15 @@ deck.count
146
146
  # => 43
147
147
  ```
148
148
 
149
+ And finally, release your hand back to the dealer:
150
+ ```ruby
151
+ my_hand.release
152
+ your_hand.release
153
+
154
+ "Deck has #{deck.count} cards, I have #{my_hand.count} cards, you have #{your_hand.count} cards"
155
+ # => "Deck has 52 cards, I have 0 cards, you have 0 cards"
156
+ ```
157
+
149
158
  # Problems?
150
159
  Please submit an [issue](https://github.com/kevinstuffandthings/fiftytwo/issues).
151
160
  We'll figure out how to get you up and running with FiftyTwo as smoothly as possible.
data/lib/fiftytwo/deck.rb CHANGED
@@ -22,9 +22,9 @@ module FiftyTwo
22
22
  end
23
23
  end
24
24
 
25
- def deal(hands, hand_size: 1)
26
- hand_size.times.each do |card_idx|
27
- hands.each { |h| h << draw }
25
+ def deal(hands, num_cards = 1)
26
+ num_cards.times.each do |card_idx|
27
+ Array(hands).each { |h| h << draw }
28
28
  end
29
29
 
30
30
  hands
data/lib/fiftytwo/hand.rb CHANGED
@@ -5,5 +5,9 @@ require_relative "./has_cards"
5
5
  module FiftyTwo
6
6
  class Hand
7
7
  include HasCards
8
+
9
+ def release
10
+ cards.reverse_each { |c| transfer(c) }
11
+ end
8
12
  end
9
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiftyTwo
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
@@ -269,7 +269,7 @@ module FiftyTwo
269
269
  card8 = subject[7]
270
270
  card9 = subject[8]
271
271
 
272
- subject.deal(hands, hand_size: 3)
272
+ subject.deal(hands, 3)
273
273
  expect(subject.count).to eq 43
274
274
  expect(hand1.cards).to match_array [card1, card4, card7]
275
275
  expect(hand2.cards).to match_array [card2, card5, card8]
@@ -2,6 +2,36 @@
2
2
 
3
3
  module FiftyTwo
4
4
  describe Hand do
5
- # covered by tests for FiftyTwo::Deck
5
+ # majority covered by tests for FiftyTwo::Deck
6
+
7
+ let(:deck) { FiftyTwo::Deck.standard }
8
+ let(:hand) { described_class.new }
9
+ before(:each) { deck.shuffle! }
10
+
11
+ describe "#release" do
12
+ it "does nothing with an empty hand" do
13
+ expect(deck.count).to eq 52
14
+ expect(hand.count).to eq 0
15
+
16
+ hand.release
17
+
18
+ expect(deck.count).to eq 52
19
+ expect(hand.count).to eq 0
20
+ end
21
+
22
+ context "with cards" do
23
+ before(:each) { deck.deal(hand, 5) }
24
+
25
+ it "can return the entirety of the hand back to the deck from whence it came" do
26
+ expect(deck.count).to eq 47
27
+ expect(hand.count).to eq 5
28
+
29
+ hand.release
30
+
31
+ expect(deck.count).to eq 52
32
+ expect(hand.count).to eq 0
33
+ end
34
+ end
35
+ end
6
36
  end
7
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiftytwo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McDonald