cribbage 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e815bde106e3529bbfc215373993536bb3b9f02a
4
- data.tar.gz: c9a125f34f365a9058400b6345dad137c957a059
3
+ metadata.gz: e8eb071f2d7d1d495312d89006b59d9bd96733a8
4
+ data.tar.gz: a82df26346d5c682a3067188ea691d5b414b73ff
5
5
  SHA512:
6
- metadata.gz: 2cbb03d76a9b9fe87cdb52662dfe83ee05e56d3f346076cc0b50522e4fd5f52e25f0df77608676f8b2935794a3be3a152f78deb908065522648f7d20263ca07e
7
- data.tar.gz: d4b1125ef7baaf5047fdf3e924ba746128c3336e9ba1685e62f99d18cda67321e66c404c2fae2cbeb02af8f12d3a72f97b5e82eca361a50c84911d00b3cb0e6f
6
+ metadata.gz: eae17feb668ad0f921a3ea609187bd1b6379663a0eb6bc1c5d911e3c0947b572cd64cf06d06434f234a9b8b2d69cb6e144804f734b78528fa9b6c2afed11a15d
7
+ data.tar.gz: 6dae959043a91b55a9e3b9d6b3789c9f7ae91da4ce3812e1b5de9b2a0d7900c18e15afc9bea7e785fe3d8048118b5a9ccac03edd67c585d0ec23cb41cca8bf5c
data/README.md CHANGED
@@ -1,41 +1,23 @@
1
1
  # Cribbage
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cribbage`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Simple gem to count a cribbage hand from the terminal.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
5
 
7
6
  ## Installation
8
7
 
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'cribbage'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
8
+ Install from your terminal's default ruby environment as:
21
9
  $ gem install cribbage
22
10
 
23
11
  ## Usage
24
12
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
13
+ Run `cribbage count` to compute points. The first argument is the flip card. The next 4 arguments are the players cards:
34
14
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cribbage.
15
+ $ cribbage count 4H 5D 6S 7C 8D
36
16
 
17
+ ### Card syntax
37
18
 
38
- ## License
19
+ The first character is the card's value. Face cards are labelled by their first letter. "J" = jack, "Q" = queen, "K" = king, and "A" = ace.
39
20
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
21
+ The last character is the card's suit. "H" = heart, "S" = spade, "D" = diamond, and "C" = club.
41
22
 
23
+ These characters are *not* case sensitive. "jD" and "Jd" would both mean a jack of diamonds.
data/lib/cribbage.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "cribbage/version"
2
+ require "cribbage/console"
2
3
  require 'awesome_print'
3
4
 
4
5
  module Cribbage
@@ -37,10 +38,6 @@ module Cribbage
37
38
  @card_str = str
38
39
  end
39
40
 
40
- def to_human_readable_format
41
- "#{@value} of #{@suit}"
42
- end
43
-
44
41
  def to_s
45
42
  "[#{@face_value}#{SUITS[@suit]}]"
46
43
  end
data/lib/cribbage/cli.rb CHANGED
@@ -2,13 +2,16 @@ require 'thor'
2
2
  require 'cribbage'
3
3
  module Cribbage
4
4
  class CLI < Thor
5
- desc "count START CARD_1 CARD_2 CARD_3 CARD_4", "count points in hand of five cards"
5
+ desc "count FLIP_CARD CARD_1 CARD_2 CARD_3 CARD_4", "count points in hand of five cards"
6
6
  def count(*cards)
7
7
 
8
+ if cards.size != 5
9
+ Console.error "You must input 5 cards"
10
+ exit
11
+ end
12
+
8
13
  hand = Cribbage::Hand.new(cards)
9
14
  hand.print_score
10
15
  end
11
-
12
- default_task :count
13
16
  end
14
17
  end
@@ -0,0 +1,13 @@
1
+ require 'cribbage'
2
+ module Cribbage
3
+
4
+ class Console
5
+
6
+ def self.error(msg)
7
+ msg = "\e[31m#{msg}\e[0m"
8
+ $stdout.printf "\n%-3s %-10s\n\n", '', msg
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Cribbage
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cribbage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - davycro
@@ -85,6 +85,7 @@ files:
85
85
  - exe/cribbage
86
86
  - lib/cribbage.rb
87
87
  - lib/cribbage/cli.rb
88
+ - lib/cribbage/console.rb
88
89
  - lib/cribbage/version.rb
89
90
  homepage:
90
91
  licenses: