card_deck 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -4
  3. data/lib/card_deck.rb +16 -4
  4. metadata +2 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e2923955364a6b2d7baad32f49294f475488c8e
4
- data.tar.gz: aad2f79a7bf43bc4e84569169c1638d03785c3a2
3
+ metadata.gz: daa2127760a7fc314d8d860e303434efaa5c910a
4
+ data.tar.gz: 2b6cd77e45a58c53849d4f9c54a677d06e7fb829
5
5
  SHA512:
6
- metadata.gz: 3cf8291cc0cc66f7442707eceffc8bd387a724ee627956b4f2f95fc05d6d50f206a698a1051257e743bac7569aee2b93719a6882f6afc07cb6f4fbb147ce372c
7
- data.tar.gz: ce7cc2f7c1979d4cff1ac2b7246f7a7ac113c5e9966b789384ef438ea36dd6eacf5643ab32ed423ca396cebeebd8d0426ec6d7f21954cf9d96fc721b83464d94
6
+ metadata.gz: 92dc4d99a30bc1af343d1d05a42d852cf5d55441e541c31e5324267800b630f42712da62a15db3e73d6c2fc9627372ac68c848739a008ca0c9936ceccf040371
7
+ data.tar.gz: 7ef948ffd37e9485a97bbde8f2387416791e3829ccc70b94a2c0ba6a5e23db8c2666765318edca5b64dad9270da8e8325a8f31f774845aeb5ee53cf6b201186d
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- ## Badges
2
- [![Gem Version](https://badge.fury.io/rb/card_deck.svg)](http://badge.fury.io/rb/card_deck)
3
1
  # card_deck
4
-
5
-
6
2
  The main component of card games
3
+
7
4
  Can include jokers
5
+ ## Badges
6
+ [![Gem Version](https://badge.fury.io/rb/card_deck.svg)](http://badge.fury.io/rb/card_deck)
7
+ [![Inline docs](http://inch-ci.org/github/zrp200/card_deck.png?branch=master)](http://inch-ci.org/github/zrp200/card_deck)
8
+ [![Code Climate](https://codeclimate.com/github/Zrp200/card_deck/badges/gpa.svg)](https://codeclimate.com/github/Zrp200/card_deck)
9
+ [![Build Status](https://travis-ci.org/Zrp200/card_deck.svg?branch=master)](https://travis-ci.org/Zrp200/card_deck)
data/lib/card_deck.rb CHANGED
@@ -1,12 +1,16 @@
1
1
  # The gem
2
2
  module CardDeck
3
+ # Gem Version
4
+ VERSION = "0.2.0"
3
5
  # Errors for when you incorrectly use a card.
4
6
  class CardError < StandardError; end
5
- class Card
7
+ class Card # The central part of any card game. It is what makes card games 'Card' games.
8
+ # Suits
9
+ HEARTS, SPADES, DIAMONDS, CLUBS = "\u2665", "\u2660", "\u2666", "\u2663"
6
10
  # Legal arguments for parameter num in Card#new.
7
11
  NUM = %w(Ace King Queen Jack Joker) + (2..10).to_a
8
12
  # Legal arguments for parameter suit in Card#new
9
- SUIT = %w(Hearts Diamonds Spades Clubs)
13
+ SUIT = [HEARTS, SPADES, DIAMONDS, CLUBS, nil]
10
14
  # The card's number. Must be Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, or Joker
11
15
  attr_accessor :num
12
16
  # The card's suit. Must be Spades, Diamonds, Clubs, Hearts, or nil.
@@ -19,12 +23,20 @@
19
23
  @num, @suit = num, suit
20
24
  end
21
25
  end
26
+ def abbreviation # The short version of the card
27
+ unless @num == "Joker"
28
+ "#{@suit}#{(@num.to_s)[0]}"
29
+ else
30
+ @num
31
+ end
32
+ end
33
+ alias abbr abbreviation # A shorter method name
22
34
  end
23
35
  # Card decks
24
36
  class Deck
25
37
  # The cards in the deck
26
38
  attr_accessor :cards
27
- # Creates a new Deck. Includes Jokers when jokers = true
39
+ # Creates a new Deck. Includes Jokers when parameter jokers = true
28
40
  def initialize(jokers=false)
29
41
  @cards = Array.new
30
42
  for suit in Card::SUIT
@@ -42,4 +54,4 @@
42
54
  @cards.push Card.new(num, suit)
43
55
  end
44
56
  end
45
- end
57
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card_deck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.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-09 00:00:00.000000000 Z
11
+ date: 2014-10-07 00:00:00.000000000 Z
12
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
13
  - !ruby/object:Gem::Dependency
28
14
  name: rspec
29
15
  requirement: !ruby/object:Gem::Requirement