Module: GamesView

Defined in:
lib/views/games_view.rb

Class Method Summary collapse

Class Method Details

.get_player_name(game) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/views/games_view.rb', line 2

def get_player_name(game)
    begin 
        game.player_name = TTY::Prompt.new.ask("\nTo record you score, please enter your name: ".colorize(:light_yellow), help: '') do |name|
            name.validate(/\w/, "Please enter a valid name (no special characters)".colorize(:red))
        end
    end while game.player_name.nil?
end

.successful_saveObject



15
16
17
18
# File 'lib/views/games_view.rb', line 15

def successful_save
    puts "Your score was saved successfully to the Leaderboard!".colorize(:white)
    sleep(2)
end

.thanks(game) ⇒ Object



10
11
12
13
# File 'lib/views/games_view.rb', line 10

def thanks(game)
    puts "\nThanks for playing, #{game.player_name}, your score was #{game.score}\n".colorize(:light_yellow)
    sleep(2)
end