fiftytwo 0.0.4 → 0.0.5

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: a8ac213d7c08c96a46422bd3591200b2ec3a96c52d67b920551147cbaf308d20
4
- data.tar.gz: 32ed65c3a39a39143e961b1ad700b55722d7a9dcaa8a9060fb14a3ea2bc54ab1
3
+ metadata.gz: bf4943f0c945d56876c500510e5b3d484aad7a10b3957372d34ce5802e1cb712
4
+ data.tar.gz: dd70bde751e33a47750c1b80174a89cc70dd3a6d94aeee084ccf8f8cec2bf9fd
5
5
  SHA512:
6
- metadata.gz: e983105544fa9d9fad75731f31d43024e219512d8da11376657b728e8616348e31d403a2137189741cb1e900fd2fec0651b36733fb8423d706522274cf48817e
7
- data.tar.gz: 586885d7b1691d9d9d003bbc9e318a21ecdeffae9de70ee6d3b384ece8a51310de31e5ac89614d7122bd2bd225aa90e3b106e504674f2960194352564946d40c
6
+ metadata.gz: 1e5d0e2f89d862a920f3660915a713ea2750f4380777cb464bf200727c8e8077901ab418869c58d1f37eda99ce33fd0a4339190b2ee323a54be310d6bd958c83
7
+ data.tar.gz: cad05b3559ac84e6cf7bced0a9dcc97ba2b5126bc5bd8ecc9b631f399865f21e84b86ea9c1e11c39fbaf9663e563408e4f97ea93089cfeff9cba5f36ce1c557b
data/README.md CHANGED
@@ -130,6 +130,12 @@ your_hand.aces.count
130
130
  # => 1
131
131
  ```
132
132
 
133
+ Examine the overall composition of a hand:
134
+ ```ruby
135
+ your_hand.suits.map(&:name) # values are ordered ascending. try ranks too!
136
+ # => ["clubs", "diamonds", "spades"]
137
+ ```
138
+
133
139
  Pass your cards around:
134
140
  ```ruby
135
141
  my_hand.transfer("4S", your_hand) # try an array of card identifiers and/or indexes, too!
@@ -29,6 +29,10 @@ module FiftyTwo
29
29
  gather(cards).map { |c| (destination || c.deck) << self.cards.delete(c) }
30
30
  end
31
31
 
32
+ %i[rank suit].each do |attribute|
33
+ define_method(attribute.to_s.pluralize) { cards.map { |c| c.send(attribute) }.uniq.sort }
34
+ end
35
+
32
36
  FiftyTwo::Suit::ALL.each do |suit|
33
37
  define_method(suit.name) { select(suit.name) }
34
38
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiftyTwo
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
@@ -56,8 +56,23 @@ module FiftyTwo
56
56
  end
57
57
  end
58
58
 
59
+ context "ranks/suits" do
60
+ let(:subject) { minideck }
61
+
62
+ it "can pull the unique ranks from a deck" do
63
+ items = subject.ranks
64
+ items.each { |i| expect(i).to be_a FiftyTwo::Rank }
65
+ expect(items.map(&:value)).to eq [3, 9, 10]
66
+ end
67
+
68
+ it "can pull the unique suits from a deck" do
69
+ items = subject.suits
70
+ items.each { |i| expect(i).to be_a FiftyTwo::Suit }
71
+ expect(items.map(&:name)).to eq %w[clubs diamonds]
72
+ end
73
+ end
74
+
59
75
  context "filtering" do
60
- require "pry"
61
76
  it "can find diamonds" do
62
77
  cards = subject.diamonds
63
78
  expect(cards.count).to eq 13
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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McDonald