class Tarzan::Games::RockPaperScissors::Move
Attributes
choice[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/tarzan/games/rock_paper_scissors/move.rb, line 11 def initialize(options = {}) @choice = options[:choice] end
valid()
click to toggle source
# File lib/tarzan/games/rock_paper_scissors/move.rb, line 7 def self.valid ['R', 'P', 'S'] end
Public Instance Methods
<=>(another)
click to toggle source
# File lib/tarzan/games/rock_paper_scissors/move.rb, line 15 def <=>(another) case "#{choice}#{another.choice}" when 'RS', 'SP', 'PR' then 1 when 'RP', 'SR', 'PS' then -1 else 0 end end
to_s()
click to toggle source
# File lib/tarzan/games/rock_paper_scissors/move.rb, line 23 def to_s "#{@choice}" end