card_deck 3.0.1 → 3.1.0.330
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 +8 -8
- data/{LICENSE → LICENSE.md} +1 -1
- data/lib/card_deck.rb +2 -2
- metadata +5 -7
- data/lib/card.rb +0 -37
- data/lib/deck.rb +0 -19
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWNlODg5ZDY2MWQ2ZjkyZjE0M2MzZmE4NzJkMTMwM2ZlNzc0Nzc5Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWU3Njk3OWIyZWIyYzY0NDFkMGQ0ZjQxNTdmNmJhMDU3YWExZDI1NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGUzZTI2MDY3NWI1Y2U2ZGRkOWJlZDQ0ZTc4ODM3MDE5MjZmOGRhZDI1M2U0
|
10
|
+
YjI0NWIzODkzOGY5YWQyM2NjMWIxYzkwMjBlZTBkYmJhYWYxZWJmMWNkZWI4
|
11
|
+
MzYwNTg3NTMwODk0YWFjYjYwMjQ3MjVlMzU1ODQxMGYyZGEwMWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzJmMzk3YTcwNGRiMGJkOGJkNTI3MDA4YzAxOTlkN2YyNjFjOTZhMmMzZWRk
|
14
|
+
Y2M3NTRhZjZlY2ZjOTg5YzI3NjM3ZGRiNjIwMmNlYzI1YmJkYTY5ZWEyYjNm
|
15
|
+
ODQ2Y2YyMTJjZTIyYzJiNmUxNTMzNTdkOWNiYTA4YmY1ZTBjY2M=
|
data/{LICENSE → LICENSE.md}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2014 Zachary Perlmutter
|
3
|
+
Copyright (c) 2014, 2015 Zachary Perlmutter
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/lib/card_deck.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require_relative "card.rb"
|
2
|
-
require_relative "deck.rb"
|
1
|
+
require_relative "card_deck/card.rb"
|
2
|
+
require_relative "card_deck/deck.rb"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card_deck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.1.0.330
|
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-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -45,13 +45,11 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files:
|
47
47
|
- README.md
|
48
|
-
- LICENSE
|
48
|
+
- LICENSE.md
|
49
49
|
files:
|
50
|
-
- LICENSE
|
50
|
+
- LICENSE.md
|
51
51
|
- README.md
|
52
|
-
- lib/card.rb
|
53
52
|
- lib/card_deck.rb
|
54
|
-
- lib/deck.rb
|
55
53
|
homepage: https://github.com/zrp200/card_deck
|
56
54
|
licenses:
|
57
55
|
- MIT
|
@@ -72,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
70
|
version: '0'
|
73
71
|
requirements: []
|
74
72
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.4.
|
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.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module CardDeck # The gem
|
2
|
-
def Card(num=Card::Num, suit=Card::Suit.sample); Card.new num, suit; end # an easier way to generate a card
|
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) + (2..10).to_a # 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 # The card's number. Must be Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, or Joker
|
9
|
-
attr_accessor :suit # The card's suit. Must be Spades, Diamonds, Clubs, or Hearts.
|
10
|
-
def initialize(num=Num.sample, suit=Suit.sample) # Creates a new card. Parameter num is the card's number. Parameter suit is the card's suit. When given no arguments, the num and suit are randomly generated
|
11
|
-
unless Suit.include? suit
|
12
|
-
suit = case suit.downcase
|
13
|
-
when "diamonds" then Diamonds
|
14
|
-
when "spades" then Spades
|
15
|
-
when "hearts" then Hearts
|
16
|
-
when "clubs" then Clubs
|
17
|
-
end
|
18
|
-
end
|
19
|
-
@num, @suit = num, suit
|
20
|
-
end
|
21
|
-
def abbreviation # The shorter representation of the card
|
22
|
-
unless @num == "Joker"
|
23
|
-
if @num == 10 then "#{@suit}#{@num}"
|
24
|
-
else
|
25
|
-
"#{@suit}#{(@num.to_s)[0]}"
|
26
|
-
end
|
27
|
-
else
|
28
|
-
@num
|
29
|
-
end
|
30
|
-
end
|
31
|
-
def black?; suit == Spades || suit == Clubs; end # Tests if the suit color is black
|
32
|
-
def red?; suit == Hearts || suit == Diamonds; end # Tests if the suit color is red
|
33
|
-
alias abbr abbreviation # A shorter method name
|
34
|
-
alias to_s abbr
|
35
|
-
alias inspect abbreviation
|
36
|
-
end
|
37
|
-
end
|
data/lib/deck.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require_relative "card.rb"
|
2
|
-
module CardDeck
|
3
|
-
class Deck # The deck
|
4
|
-
attr_accessor :cards # The cards in the deck
|
5
|
-
def initialize(args=Hash.new(false)) # Creates a new Deck. Includes Jokers when parmeter args == {jokers: true}
|
6
|
-
@cards = Array.new
|
7
|
-
for suit in Card::Suit
|
8
|
-
stock 'Ace', suit
|
9
|
-
for num in (2..10).to_a; stock num, suit; end
|
10
|
-
stock 'Jack', suit
|
11
|
-
stock 'Queen', suit
|
12
|
-
stock 'King', suit
|
13
|
-
end
|
14
|
-
2.times {stock 'Joker'} if args[:jokers]
|
15
|
-
end
|
16
|
-
private
|
17
|
-
def stock(num, suit=Card::Suit.sample); @cards.push Card.new num, suit; end # Creates a Card to add to Deck#cards
|
18
|
-
end
|
19
|
-
end
|