Class: RSokoban::MoveResult

Inherits:
Object
  • Object
show all
Defined in:
lib/rsokoban/move_result.rb

Overview

Since:

  • 0.74

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ MoveResult

Returns a new instance of MoveResult.

Parameters:

  • hash (Hash)

    the result

Options Hash (hash):

  • :status (Symbol)

    Could be :ok, :win or :error

  • :move_number (Fixnum)

    for a status of :ok or :win

  • :message (String)

    for a status of :error

Since:

  • 0.74



12
13
14
# File 'lib/rsokoban/move_result.rb', line 12

def initialize hash
	@hash = hash
end

Instance Method Details

#[](key) ⇒ Object

Since:

  • 0.74



16
17
18
# File 'lib/rsokoban/move_result.rb', line 16

def [](key)
	@hash[key]
end

#error?Boolean

Returns true if move is an error.

Returns:

  • (Boolean)

    true if move is an error

Since:

  • 0.74



31
32
33
# File 'lib/rsokoban/move_result.rb', line 31

def error?
	@hash[:status] == :error
end

#ok?Boolean

Returns true if move is ok.

Returns:

  • (Boolean)

    true if move is ok

Since:

  • 0.74



21
22
23
# File 'lib/rsokoban/move_result.rb', line 21

def ok?
	@hash[:status] == :ok
end

#win?Boolean

Returns true if move result to winning the game.

Returns:

  • (Boolean)

    true if move result to winning the game

Since:

  • 0.74



26
27
28
# File 'lib/rsokoban/move_result.rb', line 26

def win?
	@hash[:status] == :win
end