module FEEN::Dumper::InHand
The pieces in hand module.
Public Class Methods
dump(piece_names)
click to toggle source
Serialize pieces in hand lists into a string.
@param piece_names [Array] A list of pieces in hand.
@example Dump a list of pieces in hand
dump(["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"
@example Dump an empty list of pieces in hand
dump([]) # => "-"
@return [String] A string representing the pieces in hand.
# File lib/feen/dumper/in_hand.rb, line 20 def self.dump(piece_names) return "-" if piece_names.empty? piece_names.sort.join(",") end