A Ruby interface for data serialization in PAN format.
Add this line to your application's Gemfile:
gem "sashite-pan"
And then execute:
bundle
Or install it yourself as:
gem install sashite-pan
Working with PAN can be very simple, for example:
require "sashite/pan"
# Emit a PAN string
actions = [
[52, 36, "♙"]
]
Sashite::PAN.dump(*actions) # => "52,36,♙"
# Parse a PAN string
Sashite::PAN.parse("52,36,♙") # => [[52, 36, "♙", nil]]
Sashite::PAN.dump([12, 4, "♘"]) # => "12,4,♘"
Sashite::PAN.parse("12,4,♘") # => [[12, 4, "♘", nil]]
Sashite::PAN.dump([33, 24, "+P", "R"]) # => "33,24,+P,R"
Sashite::PAN.parse("33,24,+P,R") # => [[33, 24, "+P", "R"]]
Sashite::PAN.dump([nil, 42, "P"]) # => "*,42,P"
Sashite::PAN.parse("*,42,P") # => [[nil, 42, "P", nil]]
In the context of a game with several possible actions per turn, like in
Western chess, more than one action could be consider like a move, and joined
thanks to the portable_move_notation
gem.
Sashite::PAN.dump([60, 62, "♔"], [63, 61, "♖"]) # => "60,62,♔;63,61,♖"
Sashite::PAN.parse("60,62,♔;63,61,♖") # => [[60, 62, "♔", nil], [63, 61, "♖", nil]]
Sashite::PAN.dump([33, 32, "♟"], [32, 40, "♟"]) # => "33,32,♟;32,40,♟"
Sashite::PAN.parse("33,32,♟;32,40,♟") # => [[33, 32, "♟", nil], [32, 40, "♟", nil]]
The code is available as open source under the terms of the MIT License.
This gem is maintained by Sashite.
With some lines of code, let's share the beauty of Chinese, Japanese and Western cultures through the game of chess!