card_deck 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +5 -0
- data/lib/card_deck.rb +42 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 99162daefc3d05f92d8a322e0a8234db5b85ad6e
|
4
|
+
data.tar.gz: 915db734d2f8634bc12cf48b11694fb8d3e90435
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a0463f996e61d3307de2b5b7836c4cf9c02897f4c8f07ffbec00aa5fb38773e74f01919eefe5b2911866c57d57fd33db9e996b9becf65942fe290a346985c07
|
7
|
+
data.tar.gz: 65358f2800c028467ca1d8d950d5862b94910cfd795e985f9e0a345a0770ebb845696dcad23046cbb8cdfac3722a0979a65660aa9da0c952deee93cb2cf2acbb
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Zachary Perlmutter
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
data/lib/card_deck.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# The gem
|
2
|
+
module CardDeck
|
3
|
+
# Errors for when you incorrectly use a card.
|
4
|
+
class CardError < StandardError; end
|
5
|
+
class Card
|
6
|
+
# Legal arguments for Card#new.
|
7
|
+
NUM = %w(Ace King Queen Jack Joker) + (2..10).to_a
|
8
|
+
# The card's number. Must be Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, or Joker
|
9
|
+
attr_accessor :num
|
10
|
+
# Creates a new card. Parameter num is the card's number.
|
11
|
+
def initialize(num)
|
12
|
+
unless NUM.include? num
|
13
|
+
raise CardError, 'Illegal argument for parameter num'
|
14
|
+
else
|
15
|
+
@num = num
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# Card decks
|
20
|
+
class Deck
|
21
|
+
# The cards in the deck
|
22
|
+
attr_accessor :cards
|
23
|
+
# Creates a new Deck. Includes Jokers when jokers = true
|
24
|
+
def initialize(jokers=false)
|
25
|
+
4.times do
|
26
|
+
stock 'Ace'
|
27
|
+
stock 'King'
|
28
|
+
stock 'Queen'
|
29
|
+
stock 'Jack'
|
30
|
+
for num in (2..10).to_a
|
31
|
+
stock num
|
32
|
+
end
|
33
|
+
end
|
34
|
+
2.times {stock 'Joker'} if jokers
|
35
|
+
end
|
36
|
+
private
|
37
|
+
# Creates a Card to add to Deck#cards
|
38
|
+
def stock(num)
|
39
|
+
@cards.push Card.new(num)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: card_deck
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zachary Perlmutter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: inch
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files:
|
46
|
+
- README.md
|
47
|
+
- LICENSE
|
48
|
+
files:
|
49
|
+
- LICENSE
|
50
|
+
- README.md
|
51
|
+
- lib/card_deck.rb
|
52
|
+
homepage: https://github.com/zrp200/card_deck
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.3.0
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: The central part of a card game
|
76
|
+
test_files: []
|
77
|
+
has_rdoc:
|