class SnakesAndLadders::Portal
Attributes
destination[R]
Public Class Methods
new(location:, destination:)
click to toggle source
Calls superclass method
SnakesAndLadders::Cell::new
# File lib/snakes_and_ladders/portal.rb, line 5 def initialize(location:, destination:) @destination = destination super(location: location) raise ArgumentError, "Location and destination can not be equal" if location.equal?(destination) end
Public Instance Methods
enter(player, board)
click to toggle source
# File lib/snakes_and_ladders/portal.rb, line 12 def enter(player, board) puts "#{player} moves to square #{location} and takes a #{type}!" board.move(player, location, destination) end
type()
click to toggle source
# File lib/snakes_and_ladders/portal.rb, line 17 def type location > destination ? :snake : :ladder end