Ruby-Poker 0.3.0

Ruby Poker has been updated! This release is largely a result of bug reports filed by Jim W. He took ruby poker to areas I had not previously thought to explore and he ran into a couple nasty bugs. They have all been fixed in Ruby-Poker 0.3.0. In addition the following changes were made that users should be aware of.

Comparing cards has changed

Before 0.3.0 two cards objects were regarded as equal if they had the same face value. Resulting in a 6 of Spades being equal to a 6 of Clubs. After some thinking I decided that I did not like that and changed it so cards must have the same face value and same suit to be considered equal. This should not affect anyone unless they are creating and comparing Card objects directly.

PokerHand#arranged_hand has been replaced by PokerHand#sort_using_rank

To sort a PokerHand there are a couple options. PokerHand#by_face will sort a PokerHand in order from least to highest. But what if you have a pair and want to sort the cards based on the hand’s poker rank. For that there is PokerHand#sort_using_rank which was previously available as PokerHand#arranged_hand but it wasn’t documented.

Handling of duplicate cards

Before 0.3.0 Ruby-Poker would not complain if you added four 8’s of Clubs to a PokerHand. I’ve added a configuration option so that you can tell Ruby-Poker to throw a tantrum if you try and add the same card to a PokerHand twice.

require 'ruby-poker'  
PokerHand.allow_duplicates = false"8c") << "8c"   # this throws a RuntimeError

allow_duplicates is set to true by default so you will not notice anything different unless you choose to opt-in to the exceptions.

That’s everything

As always you can install ruby-poker with the gem command.

gem install ruby-poker

Or gem update ruby-poker if you already have it installed to upgrade from an old version.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>