cards_lib 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/lib/cards_lib/deck.rb +2 -1
- data/lib/cards_lib/ranker.rb +4 -0
- data/lib/cards_lib/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1bb4141856d6efdd82f36541751260759e812cf
|
4
|
+
data.tar.gz: df5377901eecdc5d3a1342327f91d2c6e5f9f80d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a71706bd2c83929d2d7af31acf4e90a81495d84079f280a5b9f86a3220c90fd6902d0e879a9a2999ca88d9b9d2d1f26c4eb02105cfeaf250ce3235c81cc6caae
|
7
|
+
data.tar.gz: 70cb115f9e01ca9437e992ee45f9ca2ea99f112087e8cb3adff7d1fd4dff08bc19a65d29cba10aa6ad4ff2de379c5c140b5ae62dd1f4e13b578a2049253cf018
|
data/.travis.yml
CHANGED
data/lib/cards_lib/deck.rb
CHANGED
@@ -2,9 +2,10 @@ module CardsLib
|
|
2
2
|
class Deck
|
3
3
|
def initialize(options = {})
|
4
4
|
cards = options.fetch(:cards) { Standard::PLAYING_CARDS }
|
5
|
+
ranker = options.fetch(:ranker){ Ranker }
|
5
6
|
@seed = options.fetch(:seed) { Random.new.seed }
|
6
7
|
@top = 0
|
7
|
-
@cards = cards.map {|c| Card.new(c) }.shuffle(random: Random.new(@seed)).to_enum
|
8
|
+
@cards = cards.map {|c| Card.new(c, ranker) }.shuffle(random: Random.new(@seed)).to_enum
|
8
9
|
end
|
9
10
|
|
10
11
|
def inspect
|
data/lib/cards_lib/ranker.rb
CHANGED
@@ -2,6 +2,10 @@ module CardsLib
|
|
2
2
|
class Ranker
|
3
3
|
include Comparable
|
4
4
|
attr :rank, :rank_lookup
|
5
|
+
# Initialize's arguments:
|
6
|
+
# rank - is whatever part of the object, or the object itself you choose to use.
|
7
|
+
# ranks - is a simple hash to lookup a cards value with the keys matching the rank object.
|
8
|
+
# rank_lookup - is an optional Proc to redefine how you will lookup a cards value.
|
5
9
|
def initialize(rank = nil, ranks = nil, rank_lookup = nil)
|
6
10
|
@rank, @ranks, @rank_lookup = rank, ranks, rank_lookup
|
7
11
|
end
|
data/lib/cards_lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cards_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.6.4
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: OO Card Game Library
|