class GooseGame::Player
Attributes
name[R]
position[RW]
to_s[R]
Public Class Methods
new(name)
click to toggle source
# File lib/goose_game/player.rb, line 6 def initialize(name) @name = name @position = START @prev = nil end
Public Instance Methods
move(pos)
click to toggle source
# File lib/goose_game/player.rb, line 14 def move(pos) return if pos == @position @prev, @position = @position, pos.to_i end
prev()
click to toggle source
# File lib/goose_game/player.rb, line 23 def prev @prev.to_i.zero? ? START : @prev end
won?()
click to toggle source
# File lib/goose_game/player.rb, line 19 def won? @position == FINISH end