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 +4 -4
- data/README.md +6 -0
- data/lib/fiftytwo/has_cards.rb +4 -0
- data/lib/fiftytwo/version.rb +1 -1
- data/spec/lib/fiftytwo/deck_spec.rb +16 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf4943f0c945d56876c500510e5b3d484aad7a10b3957372d34ce5802e1cb712
|
4
|
+
data.tar.gz: dd70bde751e33a47750c1b80174a89cc70dd3a6d94aeee084ccf8f8cec2bf9fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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!
|
data/lib/fiftytwo/has_cards.rb
CHANGED
@@ -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
|
data/lib/fiftytwo/version.rb
CHANGED
@@ -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
|