Module: FEEN::Parser::InHand

Defined in:
lib/feen/parser/in_hand.rb

Overview

The pieces in hand module.

Class Method Summary collapse

Class Method Details

.parse(piece_names_str) ⇒ Array

The list of pieces in hand grouped by players.

Examples:

Parse a list of serialized pieces in hand

parse("S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
# => ["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"]

Parse an empty list of serialized pieces in hand

parse("-")
# => []

Parameters:

  • piece_names_str (String)

    The serialized list of pieces in hand.

Returns:

  • (Array)

    The list of pieces in hand grouped by players.



20
21
22
23
24
# File 'lib/feen/parser/in_hand.rb', line 20

def self.parse(piece_names_str)
  return [] if piece_names_str == "-"

  piece_names_str.split(",")
end