Ruby-Poker 0.2.4
I just pushed out another release of the ruby-poker gem. The only change in this release is some code changes to achieve compatibility with Ruby 1.9.
Initially I had thought that I would not need to change anything for 1.9 because ruby-poker-0.2.2 installed and ran through some quick examples without any trouble. However, I was saved by my test suite when it quickly exposed a problem where I was calling each on a String object. The each method was removed from String in 1.9 so I made a quick change to work around it and once again I’m seeing nothing but dots.

Eager Loading with Ultrasphinx
Ultrasphinx is a great Rails plugin that wraps around the Sphinx full-text search engine. I am using Ultrasphinx to handle search queries on a personal project I’m working on and I ran into a situation where I wanted to eager load associated models for my search results. The method for doing this is not well documented so I’m going to step through how to add eager loading to your Ultrasphinx searches.
I am actually going to show two ways to do this. The first is the way that Evan Weaver, the creator of Ultrasphinx, recommends and the second way is the create a simple plugin that extends the Ultrasphinx plugin. The second way is my favorite because it provides the cleanest integration in my opinion but I’m going to demonstrate both methods so you can choose for yourself.
Ruby-Poker 0.2.1
Ruby-Poker 0.2.1 is an incremental update over the 0.2.0 release. The biggest change is the addition of the << and delete methods to the PokerHand object. Making it possible to add and remove cards from a hand without creating a new PokerHand object.
require 'rubygems' require 'ruby-poker' hand.PokerHand.new("3d 3s 7h 7d") hand.to_s # => "3d 3s 7h 7d (Two pair)" hand << "7c" hand.to_s # => "3d 3s 7h 7d 7c (Full house)" hand.delete("3d") hand.delete("3s") hand.to_s # => 7h 7d 7c (Three of a kind)"
I’m always in the process of adding documentation to ruby-poker. At this point the majority of the public facing methods of the PokerHand and Card classes have been documented with examples. The ruby-docs are available online at http://rubypoker.rubyforge.org/.
Rails has a low learning curve? Hardly. You need to know Ruby

Ruby on Rails is often (incorrectly) billed as the framework that makes web development easy. Unfortunately a lot of people take this to mean “Anyone can make a web site with Rails” or “You can get started with Rails in 15 minutes“. Unfortunately neither is the case but regardless hundreds of thousands of people1 are flocking to Rails to start making a web app for everything under the sun.
These people learn in hurry that Rails is actually quite a large beast2 and jump right into working with Rails without taking time to learn the programming language that Rails uses… Ruby. Almost like Ruby doesn’t exist. If I had to guess I would say people coding Rails apps without actually knowing Ruby has inevitably lead to the Rails community’s pseudo status as a ghetto.
I must confess, I was one of the Rails coders who didn’t know Ruby when I first started with Rails. Very few people who come to Rails known Ruby due to Ruby’s limited popularity before Rails came along. For about the past 7 months I have been trudging along, learning more about Ruby every day3 and the code I write for Rails projects now is much better. Ruby programming constructs like blocks, lamba, proc, etc are fairly advanced topics that I am probably only beginning to comprehend.
Most people might think it is obvious that you would need to know a framework’s programming language before you started using the framework. Certainly you would not attempt J2EE development without first knowing Java. For some reason this has not always been the case with Rails.
-
Instant Rails has been downloaded over 400,000 times. ↩
-
The Rails Way which contains everything a Rails developer needs to know about Rails is 912 pages. ↩
-
Largely thanks to Project Euler. ↩
What’s New in Ruby-Poker 0.2.0
Yesterday ruby-poker 0.2.0 was released. Here is a synopsis of what has changed.
Hands are no longer limited to 5 cards!
In order to play any poker game other than 5-card draw (like Texas Holdem) you need to evaluate hands containing more or less than 5 cards. Now you can with ruby-poker.
holdem_hand = PokerHand.new("Qc Qd Qs 5d 5h 8c 2h") # Any number of cards you want
