Sashite.Snn.StyleName (Sashite.Snn v2.0.0)

View Source

Represents a validated SNN (Style Name Notation) style name.

A StyleName encodes a single attribute:

  • name: the validated SNN string (PascalCase with optional numeric suffix)

StyleName structs are immutable. The name is validated upon creation.

Examples

iex> snn = Sashite.Snn.StyleName.new("Chess")
iex> snn.name
"Chess"

iex> snn = Sashite.Snn.StyleName.new("Chess960")
iex> Sashite.Snn.StyleName.to_string(snn)
"Chess960"

See: https://sashite.dev/specs/snn/1.0.0/

Summary

Types

t()

An SNN style name struct

Functions

Creates a new StyleName with the given name.

Returns the SNN string representation.

Types

t()

@type t() :: %Sashite.Snn.StyleName{name: String.t()}

An SNN style name struct

Functions

new(name)

@spec new(String.t()) :: t()

Creates a new StyleName with the given name.

Parameters

  • name - The SNN string (must be valid PascalCase format)

Returns

A new %StyleName{} struct.

Raises

Examples

iex> snn = Sashite.Snn.StyleName.new("Chess")
iex> snn.name
"Chess"

iex> snn = Sashite.Snn.StyleName.new("Chess960")
iex> snn.name
"Chess960"

iex> Sashite.Snn.StyleName.new("chess")
** (ArgumentError) invalid format

iex> Sashite.Snn.StyleName.new("")
** (ArgumentError) empty input

to_string(style_name)

@spec to_string(t()) :: String.t()

Returns the SNN string representation.

Examples

iex> snn = Sashite.Snn.StyleName.new("Chess")
iex> Sashite.Snn.StyleName.to_string(snn)
"Chess"

iex> snn = Sashite.Snn.StyleName.new("Xiangqi")
iex> Sashite.Snn.StyleName.to_string(snn)
"Xiangqi"