Class: ChessOpeningsHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/chess_openings/chess_openings_helper.rb

Overview

Helper class with utility functions

Class Method Summary collapse

Class Method Details

.moves_as_strings(moves) ⇒ Array

Transform contents of array to strings

Parameters:

  • moves (Array)

    Moves as strings or symbols

Returns:

  • (Array)

    Array with all moves as strings



15
16
17
# File 'lib/chess_openings/chess_openings_helper.rb', line 15

def self.moves_as_strings(moves)
  moves.map { |move| move.is_a?(Symbol) ? move.to_s : move }
end

.moves_as_symbols(moves) ⇒ Array

Transform contents of array to symbols

Parameters:

  • moves (Array)

    Moves as strings or symbols

Returns:

  • (Array)

    Array with all moves as symbols



7
8
9
# File 'lib/chess_openings/chess_openings_helper.rb', line 7

def self.moves_as_symbols(moves)
  moves.map { |move| move.is_a?(String) ? move.to_sym : move }
end