go-rank

Get Version

0.0.5

What

Go-Rank is a class for handling ranks in the game of Go.

Installing

sudo gem install go-rank

The basics

Demonstration of usage

require 'rubygems'
require 'gorank'

# create a go-rank object
rank = GoRank.new 30, :kyu  # 30 kyu is the lowest
                            #  7 dan is the highest rank

puts rank.to_s # => '30 kyu'

# one level higher:

rank += 1
puts rank.to_s # => '29 kyu'


# one level lower:

rank -= 1
puts rank.to_s # => '30 kyu'

# cannot go lower:
begin
  rank -= 1      # => raises IndexError
  puts rank.to_s 
rescue
  #
end

# change from kyu to dan rank

rank = GoRank.new 1, :kyu
puts rank.to_s   # => '1 kyu'
rank += 1
puts rank.to_s   # => '1 dan'
rank += 1
puts rank.to_s   # => '2 dan'

# difference between two ranks

rank1 = GoRank.new 1, :dan
rank2 = GoRank.new 5, :kyu

puts "difference between #{rank1} and #{rank2} is #{rank1-rank2} stones"
         # => "difference between 1 dan and 5 kyu is 5 stones"

# comparing ranks
# a better rank is greater than a lower rank

puts GoRank.new(1,:dan) > GoRank(5,:kyu) # => true
puts GoRank.new(1,:dan) == GoRank(1,:dan) # => true
puts GoRank.new(1,:dan) < GoRank(5,:kyu) # => false

# invalid ranks

rank = GoRank.new 35, :kyu # => raises ArgumentError

Forum

http://groups.google.com/group/gorank

How to submit patches

Read the 8 steps for fixing other people’s code and for section 8b: Submit patch to Google Groups, use the Google Group above.

The trunk repository is svn://rubyforge.org/var/svn/gorank/trunk for anonymous access.

License

This code is free to use under the terms of the MIT license.

Contact

Comments are welcome. Send an email to Thomas Preymesser.

Thomas Preymesser, 10th January 2009
Theme extended from Paul Battley