lib/pgn/move_calculator.rb
# Using the current position and move, figure out where the piece
# came from.
#
Using the current position and move, figure out where the piece
came from.
Using the current position and move figure out where the piece came from .
def compute_origin
      return nil if move.castle
      possibilities = case move.piece
      when /[brq]/i then direction_origins
      when /[kn]/i  then move_origins
      when /p/i     then pawn_origins
      end
      if possibilities.length > 1
        possibilities = disambiguate(possibilities)
      end
      self.board.position_for(possibilities.first)
    end
def compute_origin return nil if move . castle possibilities = case move . piece when / [brq] /i then direction_origins when / [kn] /i then move_origins when / p /i then pawn_origins end if possibilities . length > 1 possibilities = disambiguate ( possibilities ) end self . board . position_for ( possibilities . first ) end
Using the current position and move, figure out where the piece
came from.
Using the current position and move figure out where the piece came from .