fiftytwo 0.0.3 → 0.0.4

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: a5c1752b761a6a418abc5635ece62d1dde656012ca5b548e107ab633a915d868
4
- data.tar.gz: f044e63524c51c7f25987f8a682e5876157bda0bbb10c2c3b7959535afbe88c3
3
+ metadata.gz: a8ac213d7c08c96a46422bd3591200b2ec3a96c52d67b920551147cbaf308d20
4
+ data.tar.gz: 32ed65c3a39a39143e961b1ad700b55722d7a9dcaa8a9060fb14a3ea2bc54ab1
5
5
  SHA512:
6
- metadata.gz: 3e413c3f029b93322be3ed98725dc99dc7621ddc2bd53f9e3d18abb417419be200b53d055620e3dbffce932e691c56dd5466d097a4ffb24800d7c20a8dfc34df
7
- data.tar.gz: a1db0d51936d8c0d20b4bf25ac1f9d9f6525e509cbe557a5b327c582c22d32831c2e0fb460a96ddf30a0826299c9e2039759937def354e1fa7851483c0f5d081
6
+ metadata.gz: e983105544fa9d9fad75731f31d43024e219512d8da11376657b728e8616348e31d403a2137189741cb1e900fd2fec0651b36733fb8423d706522274cf48817e
7
+ data.tar.gz: 586885d7b1691d9d9d003bbc9e318a21ecdeffae9de70ee6d3b384ece8a51310de31e5ac89614d7122bd2bd225aa90e3b106e504674f2960194352564946d40c
data/README.md CHANGED
@@ -132,7 +132,7 @@ your_hand.aces.count
132
132
 
133
133
  Pass your cards around:
134
134
  ```ruby
135
- my_hand.transfer("4S", your_hand) # try an array of card identifiers, too!
135
+ my_hand.transfer("4S", your_hand) # try an array of card identifiers and/or indexes, too!
136
136
  puts my_hand.render, your_hand.render
137
137
  # 3♦ 5♦ 7♥ 2♣
138
138
  # 5♠ 6♠ 10♦ Q♣ A♦ 4♠
@@ -21,6 +21,7 @@ module FiftyTwo
21
21
  end
22
22
 
23
23
  def locate(identifier)
24
+ return cards[identifier] if identifier.is_a?(Integer)
24
25
  cards.find { |c| c.identifier == identifier.upcase }
25
26
  end
26
27
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiftyTwo
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
@@ -186,20 +186,32 @@ module FiftyTwo
186
186
 
187
187
  it "can transfer a card by object" do
188
188
  subject.transfer(subject[1], hand)
189
- expect(subject.count).to eq 2
190
- expect(hand.count).to eq 1
189
+ expect(subject.map(&:identifier)).to match_array ["3C", "10D"]
190
+ expect(hand.map(&:identifier)).to match_array ["9D"]
191
191
  end
192
192
 
193
193
  it "can transfer a card by identifier" do
194
194
  subject.transfer("3C", hand)
195
- expect(subject.count).to eq 2
196
- expect(hand.count).to eq 1
195
+ expect(subject.map(&:identifier)).to match_array ["9D", "10D"]
196
+ expect(hand.map(&:identifier)).to match_array ["3C"]
197
+ end
198
+
199
+ it "can transfer a card by index" do
200
+ subject.transfer(0, hand)
201
+ expect(subject.map(&:identifier)).to match_array ["9D", "10D"]
202
+ expect(hand.map(&:identifier)).to match_array ["3C"]
197
203
  end
198
204
 
199
205
  it "can transfer multiple cards" do
200
206
  subject.transfer(%w[3C 10D], hand)
201
- expect(subject.count).to eq 1
202
- expect(hand.count).to eq 2
207
+ expect(subject.map(&:identifier)).to match_array ["9D"]
208
+ expect(hand.map(&:identifier)).to match_array ["3C", "10D"]
209
+ end
210
+
211
+ it "can transfer multiple cards by a variety of identification methods" do
212
+ subject.transfer(["3C", 1], hand)
213
+ expect(subject.map(&:identifier)).to match_array ["10D"]
214
+ expect(hand.map(&:identifier)).to match_array ["3C", "9D"]
203
215
  end
204
216
 
205
217
  it "will not transfer any and raise an error if any one card reference is invalid" do
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McDonald