Module: Chess::UTF8Notation
- Defined in:
- lib/chess/utf8_notation.rb
Overview
Note:
To use this utility explicit require is needed: require 'chess/utf8_notation'
With this module is possible call the method #to_utf8 on a string. This method convert the chess piece identifier character into UTF8 chess character.
Constant Summary collapse
- UTF8_MAP =
Map a piece identifier character with the corresponding UTF8 chess character
{ 'P' => '♙', 'R' => '♖', 'N' => '♘', 'B' => '♗', 'Q' => '♕', 'K' => '♔', 'p' => '♟', 'r' => '♜', 'n' => '♞', 'b' => '♝', 'q' => '♛', 'k' => '♚' }.freeze
Instance Method Summary collapse
-
#to_utf8 ⇒ String
Replace the piece identifier characters with UTF8 chess characters.
Instance Method Details
#to_utf8 ⇒ String
Replace the piece identifier characters with UTF8 chess characters.
33 34 35 |
# File 'lib/chess/utf8_notation.rb', line 33 def to_utf8 self.gsub(/[PRNBQKprnbqk]/, UTF8_MAP) end |