Sha256: 22c6eded1c709eef3d0bd81b6c2c1bd4d6d27e8bd3ad094daf577aa53e4c9244

Contents?: true

Size: 583 Bytes

Versions: 3

Compression:

Stored size: 583 Bytes

Contents

# Helper class with utility functions
class ChessOpeningsHelper
  # Transform contents of array to symbols
  #
  # @param [Array] moves Moves as strings or symbols
  # @return [Array] Array with all moves as symbols
  def self.moves_as_symbols(moves)
    moves.map { |move| move.is_a?(String) ? move.to_sym : move }
  end

  # Transform contents of array to strings
  #
  # @param [Array] moves Moves as strings or symbols
  # @return [Array] Array with all moves as strings
  def self.moves_as_strings(moves)
    moves.map { |move| move.is_a?(Symbol) ? move.to_s : move }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chess_openings-1.0.2 lib/chess_openings/chess_openings_helper.rb
chess_openings-1.0.1 lib/chess_openings/chess_openings_helper.rb
chess_openings-1.0.0 lib/chess_openings/chess_openings_helper.rb