Module: Sashite::Drop

Defined in:
lib/sashite/drop.rb

Overview

DROP (Droppable Reserve Operations Placement) implementation

DROP defines a simple, standardized notation for piece reserve locations in board games where captured pieces can be held and/or placed onto the board.

Examples:

Basic usage

Sashite::Drop.reserve?("*")     # => true
Sashite::Drop.reserve?("a1")    # => false
Sashite::Drop.to_s              # => "*"

See Also:

Since:

  • 1.0.0

Constant Summary collapse

RESERVE =

The reserve location character

Since:

  • 1.0.0

"*"

Class Method Summary collapse

Class Method Details

.reserve?(string) ⇒ Boolean

Check if a string represents the reserve location

Examples:

Sashite::Drop.reserve?("*")   # => true
Sashite::Drop.reserve?("a1")  # => false
Sashite::Drop.reserve?("**")  # => false
Sashite::Drop.reserve?("")    # => false

Parameters:

  • the string to check

Returns:

  • true if the string is the reserve location

Since:

  • 1.0.0



31
32
33
# File 'lib/sashite/drop.rb', line 31

def self.reserve?(string)
  RESERVE.eql?(string)
end

.to_sString

Get the canonical DROP representation

Examples:

Sashite::Drop.to_s            # => "*"

Returns:

  • the reserve location character

Since:

  • 1.0.0



41
42
43
# File 'lib/sashite/drop.rb', line 41

def self.to_s
  RESERVE
end