Module: Sashite::Feen::Dumper::PiecePlacement
- Defined in:
- lib/sashite/feen/dumper/piece_placement.rb
Overview
Dumper for the piece placement field (first field of FEEN).
Converts a Placement object into its FEEN string representation, encoding board configuration using EPIN notation with:
-
Empty square compression (consecutive nils → numbers)
-
Exact separator preservation (from Placement.separators)
-
Support for any irregular board structure
The dumper produces canonical FEEN strings that enable perfect round-trip conversion (dump → parse → dump).
Class Method Summary collapse
-
.dump(placement) ⇒ String
Dump a Placement object into its FEEN piece placement string.
Class Method Details
.dump(placement) ⇒ String
Dump a Placement object into its FEEN piece placement string.
Process:
-
For 1D boards: dump single rank directly
-
For multi-D boards: interleave ranks with their separators
-
Compress consecutive empty squares into numbers
-
Convert pieces to EPIN strings
49 50 51 52 53 54 55 |
# File 'lib/sashite/feen/dumper/piece_placement.rb', line 49 def self.dump(placement) # Special case: 1D board (no separators) return dump_rank(placement.ranks[0]) if placement.one_dimensional? # Multi-dimensional: interleave ranks and separators dump_multi_dimensional(placement) end |