decko_cards 0.0.0
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.
- data/lib/decko_cards.rb +55 -0
- metadata +46 -0
data/lib/decko_cards.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
class Decko_cards
|
2
|
+
attr_reader :cards
|
3
|
+
|
4
|
+
def initialize(aces=:h)
|
5
|
+
@cards = gen(aces)
|
6
|
+
end
|
7
|
+
|
8
|
+
def deal
|
9
|
+
@cards.shuffle!.pop
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def suits
|
14
|
+
@suits = ['Spades', 'Diamonds', 'Clubs', 'Hearts']
|
15
|
+
end
|
16
|
+
|
17
|
+
def ranks
|
18
|
+
@ranks = {'Two'=>2, 'Three'=>3, 'Four'=>4, 'Five'=>5,
|
19
|
+
'Six'=>6, 'Seven'=>7, 'Eight'=>8, 'Nine'=>9, 'Ten'=>10,
|
20
|
+
'Jack'=>10, 'Queen'=>10, 'King'=>10, 'Ace'=>11}
|
21
|
+
end
|
22
|
+
|
23
|
+
def gen(aces)
|
24
|
+
r = ace_make(aces)
|
25
|
+
deck_make(suits, r)
|
26
|
+
end
|
27
|
+
|
28
|
+
def ace_make(aces)
|
29
|
+
r = ranks
|
30
|
+
if aces == :l
|
31
|
+
r['Ace']= 1
|
32
|
+
elsif aces == :w
|
33
|
+
r.each {
|
34
|
+
|c, v| r[c]=Array(v)
|
35
|
+
}
|
36
|
+
r['Ace'] << 1
|
37
|
+
end
|
38
|
+
r
|
39
|
+
end
|
40
|
+
|
41
|
+
def deck_make(list, hash)
|
42
|
+
d = []
|
43
|
+
for s in list
|
44
|
+
hash.each { |r, v|
|
45
|
+
d << {
|
46
|
+
:name =>"#{r} of #{s}",
|
47
|
+
:suit =>s.to_sym,
|
48
|
+
:rank => r.to_sym,
|
49
|
+
:value => v
|
50
|
+
}
|
51
|
+
}
|
52
|
+
end
|
53
|
+
d
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: decko_cards
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- J Kiely
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A gem that makes a deck of cards and lets you deal them
|
15
|
+
email: jjkiely@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/decko_cards.rb
|
21
|
+
homepage: https://github.com/JKiely/Decko_cards
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 1.8.23
|
43
|
+
signing_key:
|
44
|
+
specification_version: 3
|
45
|
+
summary: A deck of cards
|
46
|
+
test_files: []
|