Module: Sashite::Hand

Defined in:
lib/sashite/hand.rb

Overview

HAND (Hold And Notation Designator) implementation

HAND defines a simple, standardized notation for piece reserve locations in board games where pieces can be held off-board and potentially placed.

Examples:

Basic usage

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

See Also:

Author:

  • Sashité

Constant Summary collapse

RESERVE =

The reserve location character

"*"

Class Method Summary collapse

Class Method Details

.reserve?(string) ⇒ Boolean

Check if a string represents the reserve location

Examples:

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

Parameters:

  • string (String)

    the string to check

Returns:

  • (Boolean)

    true if the string is the reserve location



30
31
32
# File 'lib/sashite/hand.rb', line 30

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

.to_sString

Get the canonical HAND representation

Examples:

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

Returns:

  • (String)

    the reserve location character



40
41
42
# File 'lib/sashite/hand.rb', line 40

def self.to_s
  RESERVE
end