card_deck 4.0.0.pre.339 → 4.0.0.pre73783052
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- metadata +9 -11
- data/lib/card_deck/card.rb +0 -51
- data/lib/card_deck/deck.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
N2NkZjg0MGI0YTBmZjkwZDE4MDVhNjhhMTRiYTYyNjQ0YjQ3NWYxMw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YWU2NjBlYzk5ZWYxMmJkMzM3MWFiZGIwZjNkZTdmY2Y5YTM0ZTFhMg==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Zjk1OGIxM2MyNjc2ZGZhYTNlZTRjMjFhZGYwYWY5ZDBjMmVkYzQ3N2ZmYzBh
|
10
|
+
N2UwNWY2MDE3NzM2YTRlZTExNmY3ODAyMmFhMTc3NWEzMTA5NzNkN2IxYzdl
|
11
|
+
NzM3MDc3YjJkMTQ5YWI2YzRmNjYzZWUwZmI5YTgwZmQ5NzdiZDQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YTIyY2RkMTdmZmZiNTE1YzhmNzgwMzYzMmJkMWRhMzcwODI4OTIwZDM0ODA4
|
14
|
+
ZmZjZTVlYWY4NmQ3ZTY3OGFkYzJiZTlhNTg2MzI2MWIwM2ZlMTFlMWYzY2M4
|
15
|
+
YWRhODlkYmY0MTE2YjNhYzE5NDU5ZTZmYzNjYTcwYWRhODNlNDc=
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card_deck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.pre73783052
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Perlmutter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec-its
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Supplies the core parts of any card game. To use the deck, call shuffle
|
@@ -50,8 +50,6 @@ files:
|
|
50
50
|
- LICENSE.md
|
51
51
|
- README.md
|
52
52
|
- lib/card_deck.rb
|
53
|
-
- lib/card_deck/card.rb
|
54
|
-
- lib/card_deck/deck.rb
|
55
53
|
homepage: https://github.com/zrp200/card_deck
|
56
54
|
licenses:
|
57
55
|
- MIT
|
@@ -62,17 +60,17 @@ require_paths:
|
|
62
60
|
- lib
|
63
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
62
|
requirements:
|
65
|
-
- -
|
63
|
+
- - ! '>='
|
66
64
|
- !ruby/object:Gem::Version
|
67
65
|
version: '0'
|
68
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
67
|
requirements:
|
70
|
-
- -
|
68
|
+
- - ! '>'
|
71
69
|
- !ruby/object:Gem::Version
|
72
70
|
version: 1.3.1
|
73
71
|
requirements: []
|
74
72
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.
|
73
|
+
rubygems_version: 2.4.5
|
76
74
|
signing_key:
|
77
75
|
specification_version: 4
|
78
76
|
summary: The central part of a card game
|
data/lib/card_deck/card.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
module CardDeck # The gem
|
2
|
-
|
3
|
-
class CardError < StandardError; end # Errors for when you incorrectly use a card.
|
4
|
-
class Card # The central part of any card game. It is what makes card games 'Card' games.
|
5
|
-
Hearts, Spades, Diamonds, Clubs = "\u2665", "\u2660", "\u2666", "\u2663" # Suits
|
6
|
-
Num = %w(Ace King Queen Jack Joker) + Array(2..10) # Legal arguments for parameter num in Card#new.
|
7
|
-
Suit = [Hearts, Spades, Diamonds, Clubs] # Legal arguments for parameter suit in Card#new
|
8
|
-
attr_accessor :num # @return [String, Fixnum] must be Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, or Joker
|
9
|
-
attr_accessor :suit # @return [String] must be spades, diamonds, clubs, or hearts
|
10
|
-
|
11
|
-
=begin
|
12
|
-
@param suit [String]
|
13
|
-
@param num [String, Fixnum]
|
14
|
-
=end
|
15
|
-
def initialize(num=Num.sample, suit=Suit.sample)
|
16
|
-
suit = Card.const_get suit.capitalize unless Suit.include? suit
|
17
|
-
@num, @suit = num, suit
|
18
|
-
end
|
19
|
-
|
20
|
-
=begin
|
21
|
-
The shorter representation of the card
|
22
|
-
@return [String]
|
23
|
-
=end
|
24
|
-
def abbreviation
|
25
|
-
unless @num == "Joker"
|
26
|
-
if @num == 10 then @suit + @num.to_s
|
27
|
-
else @suit + Array(@num.to_s).fetch(0) end
|
28
|
-
else @num.to_s end
|
29
|
-
end
|
30
|
-
def black? # @return [Boolean]
|
31
|
-
suit == Spades || suit == Clubs
|
32
|
-
end
|
33
|
-
def red? # @return [Boolean]
|
34
|
-
suit == Hearts || suit == Diamonds
|
35
|
-
end
|
36
|
-
alias abbr abbreviation
|
37
|
-
alias to_s abbr
|
38
|
-
alias inspect abbreviation
|
39
|
-
end
|
40
|
-
module_function
|
41
|
-
=begin
|
42
|
-
@return [Card]
|
43
|
-
@param [String, Fixnum] num
|
44
|
-
@param [String] suit
|
45
|
-
@see Card#initialize
|
46
|
-
An easier way to generate a card
|
47
|
-
=end
|
48
|
-
def Card(num=Card::Num.sample, suit=Card::Suit.sample)
|
49
|
-
Card.new num, suit
|
50
|
-
end
|
51
|
-
end
|
data/lib/card_deck/deck.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require "card_deck/card"
|
2
|
-
module CardDeck
|
3
|
-
def Deck(args=Hash.new(false))
|
4
|
-
Deck.new args
|
5
|
-
end
|
6
|
-
class Deck # The deck
|
7
|
-
attr_accessor :cards # @return [Array<Card>]
|
8
|
-
def initialize(args=Hash.new(false)) # Creates a new Deck. Includes Jokers when parmeter args == {jokers: true}
|
9
|
-
@cards = Array.new
|
10
|
-
Card::Suit.each do |suit|
|
11
|
-
stock 'Ace', suit
|
12
|
-
(2..10).each {|num| stock num, suit}
|
13
|
-
stock 'Jack', suit
|
14
|
-
stock 'Queen', suit
|
15
|
-
stock 'King', suit
|
16
|
-
end
|
17
|
-
2.times {stock 'Joker'} if args[:jokers]
|
18
|
-
end
|
19
|
-
private
|
20
|
-
def stock(num, suit=Card::Suit.sample) # Creates a Card to add to Deck#cards
|
21
|
-
@cards.push Card.new num, suit
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|