class Egd::FenBuilder

Constants

NULL_FEN

Attributes

move[R]

This service takes in a FEN string and a chess move in algebraic notation. Outputs the FEN of the resulting position

start_fen[R]

This service takes in a FEN string and a chess move in algebraic notation. Outputs the FEN of the resulting position

Public Class Methods

new(start_fen: nil, move: nil) click to toggle source

Egd::FenBuilder.new(start_fen: nil, move:).call

# File lib/egd/fen_builder.rb, line 11
def initialize(start_fen: nil, move: nil)
  @start_fen = start_fen || NULL_FEN
  @move = move.to_s.gsub(%r'\A\d+\.\s*\.*\s*', "")
end

Public Instance Methods

call() click to toggle source
# File lib/egd/fen_builder.rb, line 16
def call
  @fen ||= (
    move != "" ?
      PGN::FEN.new(start_fen).to_position.move(move).to_fen.to_s :
      @start_fen
  )
end