Sha256: d37b57f9cb463943364638fef9e925b60628c631e5d1129d0fe1dbaa9d853666
Contents?: true
Size: 530 Bytes
Versions: 1
Compression:
Stored size: 530 Bytes
Contents
module Tarzan module Games module RockPaperScissors class Move attr_reader :choice def self.valid ['R', 'P', 'S'] end def initialize(options = {}) @choice = options[:choice] end def <=>(another) case "#{choice}#{another.choice}" when 'RS', 'SP', 'PR' then 1 when 'RP', 'SR', 'PS' then -1 else 0 end end def to_s "#{@choice}" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tarzan-0.0.3 | lib/tarzan/games/rock_paper_scissors/move.rb |