card_deck 0.0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/card_deck.rb +18 -14
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de94a936513d0729946b917ef1f701d2a7978d3b
4
- data.tar.gz: 3a6e9646b264cf348580dacc8906d96799aa3ac6
3
+ metadata.gz: 165bddc72fe986cd53606675edb609a31730fd0a
4
+ data.tar.gz: 156717251856aaa038ea09e372802975f0b56e89
5
5
  SHA512:
6
- metadata.gz: ab8346359a5659ce011742edb0cbffb5bba51aa9562c6751c2b6d0b668409833bb0ff8da020e05f087db8a09edffe3dff756d4d76ea82f1a1040a2ce53f19839
7
- data.tar.gz: 65eaac7eaca3f0e70aeae6f70a6ac37865ce9f6ef2f463b60d8a6d5bbad1a3558ad85147efca2fe5f851ba3acedc86b3cdcefa1b30f7b03171bd7bbbb114580c
6
+ metadata.gz: e1b85d1e15c1c590967e0f4c77394dc3c6e7403cf7c319038a9723d03209c9c3a87c5ad359900052c7568eccba4f0ffd2eea837100c5a533afd98704cc9e6d85
7
+ data.tar.gz: 697d246360fba34c8e0eb064ab2e439ca82b5ad1fec23773a506eabec99ece90c356e064a0d7ea5f632bffa77c1d36aeaf06645ce0b5e6231e57535894e36f02
data/lib/card_deck.rb CHANGED
@@ -3,16 +3,20 @@
3
3
  # Errors for when you incorrectly use a card.
4
4
  class CardError < StandardError; end
5
5
  class Card
6
- # Legal arguments for Card#new.
6
+ # Legal arguments for parameter num in Card#new.
7
7
  NUM = %w(Ace King Queen Jack Joker) + (2..10).to_a
8
+ # Legal arguments for parameter suit in Card#new
9
+ SUIT = %w(Hearts Diamonds Spades Clubs)
8
10
  # The card's number. Must be Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, or Joker
9
11
  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'
12
+ # The card's suit. Must be Spades, Diamonds, Clubs, Hearts, or nil.
13
+ attr_accessor :suit
14
+ # Creates a new card. Parameter num is the card's number. Parameter suit is the card's suit
15
+ def initialize(num, suit=nil)
16
+ unless NUM.include?(num) || SUIT.include?(suit) || suit.nil?
17
+ raise CardError, 'Illegal argument'
14
18
  else
15
- @num = num
19
+ @num, @suit = num, suit
16
20
  end
17
21
  end
18
22
  end
@@ -23,21 +27,21 @@
23
27
  # Creates a new Deck. Includes Jokers when jokers = true
24
28
  def initialize(jokers=false)
25
29
  @cards = Array.new
26
- 4.times do
27
- stock 'Ace'
28
- stock 'King'
29
- stock 'Queen'
30
- stock 'Jack'
30
+ for suit in Card::SUIT
31
+ stock 'Ace', suit
32
+ stock 'King', suit
33
+ stock 'Queen', suit
34
+ stock 'Jack', suit
31
35
  for num in (2..10).to_a
32
- stock num
36
+ stock num, suit
33
37
  end
34
38
  end
35
39
  2.times {stock 'Joker'} if jokers
36
40
  end
37
41
  private
38
42
  # Creates a Card to add to Deck#cards
39
- def stock(num)
40
- @cards.push Card.new(num)
43
+ def stock(num, suit=nil)
44
+ @cards.push Card.new(num, suit)
41
45
  end
42
46
  end
43
47
  end
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: 0.0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Perlmutter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-05 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inch
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  version: '0'
70
70
  requirements: []
71
71
  rubyforge_project:
72
- rubygems_version: 2.4.1
72
+ rubygems_version: 2.3.0
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: The central part of a card game