HAND (Hold And Notation Designator) implementation for Ruby.
This library implements the HAND Specification v1.0.0.
# In your Gemfile
gem "sashite-hand"Or install manually:
gem install sashite-handConvert a HAND string into a symbol.
require "sashite/hand"
# Standard parsing (raises on error)
Sashite::Hand.parse("*") # => :"*"
# Invalid input raises ArgumentError
Sashite::Hand.parse("e4") # => raises ArgumentError
Sashite::Hand.parse("") # => raises ArgumentError# Boolean check
Sashite::Hand.valid?("*") # => true
Sashite::Hand.valid?("e4") # => false
Sashite::Hand.valid?("") # => false# Access the HAND notation symbol
Sashite::Hand::NOTATION # => :"*"
# Convert to string when needed
Sashite::Hand::NOTATION.to_s # => "*"Sashite::Hand::NOTATION # => :"*"# Parses a HAND string into a symbol.
# Raises ArgumentError if the string is not valid.
#
# @param input [String] HAND notation string
# @return [Symbol] the :"*" symbol
# @raise [ArgumentError] if invalid
def Sashite::Hand.parse(input)# Validates a HAND string.
# Raises ArgumentError with descriptive message if invalid.
#
# @param input [String] HAND notation string
# @return [nil]
# @raise [ArgumentError] if invalid
def Sashite::Hand.validate(input)
# Reports whether string is a valid HAND notation.
#
# @param input [String] HAND notation string
# @return [Boolean]
def Sashite::Hand.valid?(input)All parsing and validation errors raise ArgumentError with descriptive messages:
| Message | Cause |
|---|---|
"invalid hand notation" |
Input is not exactly * |
begin
Sashite::Hand.parse("**")
rescue ArgumentError => e
puts e.message # => "invalid hand notation"
end- Symbol-based: Notation represented as Ruby symbol for identity semantics
- Minimal: Single constant and three methods
- Ruby idioms:
valid?predicate,parseconversion - Strict validation: Only the
*character is accepted - No dependencies: Pure Ruby standard library only
- Game Protocol — Conceptual foundation
- HAND Specification — Official specification
- CELL Specification — Complementary notation for Board squares
Available as open source under the Apache License 2.0.