Module: Sashite::Sin

Defined in:
lib/sashite/sin.rb,
lib/sashite/sin/identifier.rb

Overview

SIN (Style Identifier Notation) implementation for Ruby

Provides a rule-agnostic format for identifying styles in abstract strategy board games. SIN uses single ASCII letters with case-based side encoding, enabling clear distinction between different style families in multi-style gaming environments.

Format: <style-letter>

  • Uppercase letter: First player styles (A, B, C, …, Z)

  • Lowercase letter: Second player styles (a, b, c, …, z)

  • Single character only: Each SIN identifier is exactly one ASCII letter

Examples:

"C"  - First player, C style family
"c"  - Second player, C style family
"S"  - First player, S style family
"s"  - Second player, S style family

See: sashite.dev/specs/sin/1.0.0/

Defined Under Namespace

Classes: Identifier

Class Method Summary collapse

Class Method Details

.identifier(letter, side) ⇒ Sin::Identifier

Create a new identifier instance

Examples:

Create identifiers directly

Sashite::Sin.identifier(:C, :first)  # => #<Sin::Identifier letter=:C side=:first>
Sashite::Sin.identifier(:s, :second) # => #<Sin::Identifier letter=:s side=:second>

Parameters:

  • letter (Symbol)

    style letter (single ASCII letter as symbol)

  • side (Symbol)

    player side (:first or :second)

Returns:

Raises:

  • (ArgumentError)

    if parameters are invalid



61
62
63
# File 'lib/sashite/sin.rb', line 61

def self.identifier(letter, side)
  Identifier.new(letter, side)
end

.parse(sin_string) ⇒ Sin::Identifier

Parse an SIN string into an Identifier object

Examples:

Parse different SIN formats

Sashite::Sin.parse("C") # => #<Sin::Identifier letter=:C side=:first>
Sashite::Sin.parse("c") # => #<Sin::Identifier letter=:c side=:second>
Sashite::Sin.parse("S") # => #<Sin::Identifier letter=:S side=:first>

Parameters:

  • sin_string (String)

    SIN notation string

Returns:

  • (Sin::Identifier)

    parsed identifier object with letter and side attributes

Raises:

  • (ArgumentError)

    if the SIN string is invalid



48
49
50
# File 'lib/sashite/sin.rb', line 48

def self.parse(sin_string)
  Identifier.parse(sin_string)
end

.valid?(sin_string) ⇒ Boolean

Check if a string is a valid SIN notation

Examples:

Validate various SIN formats

Sashite::Sin.valid?("C") # => true
Sashite::Sin.valid?("c") # => true
Sashite::Sin.valid?("CHESS") # => false (multi-character)
Sashite::Sin.valid?("1") # => false (not a letter)

Parameters:

  • sin_string (String)

    the string to validate

Returns:

  • (Boolean)

    true if valid SIN, false otherwise



35
36
37
# File 'lib/sashite/sin.rb', line 35

def self.valid?(sin_string)
  Identifier.valid?(sin_string)
end