Class: Output::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/console_app/output.rb

Constant Summary collapse

ARROW =
'~> '.freeze

Class Method Summary collapse

Class Method Details

.clearObject



6
7
8
# File 'lib/console_app/output.rb', line 6

def clear
  system('clear')
end

.difficult_errorObject



90
91
92
# File 'lib/console_app/output.rb', line 90

def difficult_error
  puts I18n.t :difficult_error
end

.game_commandsObject



64
65
66
# File 'lib/console_app/output.rb', line 64

def game_commands
  puts I18n.t :game_commands
end

.get_hint(game) ⇒ Object



47
48
49
50
51
# File 'lib/console_app/output.rb', line 47

def get_hint(game)
  return Messages.hint_error if game.hints.zero?

  puts "[#{game.use_hint}] - one of the number"
end

.hint_errorObject



94
95
96
# File 'lib/console_app/output.rb', line 94

def hint_error
  puts I18n.t :hint_error
end

.loseObject



86
87
88
# File 'lib/console_app/output.rb', line 86

def lose
  puts I18n.t :lose
end

.name_errorObject



82
83
84
# File 'lib/console_app/output.rb', line 82

def name_error
  puts I18n.t :name_error, min: 3, max: 20
end

.save_statsObject



77
78
79
80
# File 'lib/console_app/output.rb', line 77

def save_stats
  puts I18n.t :save_stats
  print ARROW
end

.show_byeObject



35
36
37
# File 'lib/console_app/output.rb', line 35

def show_bye
  puts I18n.t :goodbye
end

.show_difficultObject



53
54
55
56
57
# File 'lib/console_app/output.rb', line 53

def show_difficult
  puts I18n.t :set_difficult
  puts I18n.t :difficult
  print ARROW
end

.show_game_info(game) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/console_app/output.rb', line 39

def show_game_info(game)
  puts '==================='
  puts I18n.t(:game_hints, hints: game.hints)
  puts I18n.t(:game_attempts, attempts: game.attempts)
  puts I18n.t :game_help
  print ARROW
end

.show_greetingObject



25
26
27
28
29
# File 'lib/console_app/output.rb', line 25

def show_greeting
  clear
  puts I18n.t :greeting
  puts I18n.t :menu
end

.show_nameObject



59
60
61
62
# File 'lib/console_app/output.rb', line 59

def show_name
  puts I18n.t :set_name, min: 3
  print ARROW
end

.show_rulesObject



31
32
33
# File 'lib/console_app/output.rb', line 31

def show_rules
  puts I18n.t :rules
end

.show_stats(stat) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/console_app/output.rb', line 14

def show_stats(stat)
  puts I18n.t(:show_stats,
              rating: stat[:rating],
              name: stat[:name],
              difficult: stat[:difficult].level,
              attempts: (stat[:attempts] + stat[:attempts_used]),
              attempts_used: stat[:attempts_used],
              hints: (stat[:hints] + stat[:hints_used]),
              hints_used: stat[:hints_used])
end

.start_againObject



68
69
70
71
# File 'lib/console_app/output.rb', line 68

def start_again
  puts I18n.t :start_again
  print ARROW
end

.stats_errorObject



10
11
12
# File 'lib/console_app/output.rb', line 10

def stats_error
  puts I18n.t :stats_error
end

.unknown_commandObject



98
99
100
# File 'lib/console_app/output.rb', line 98

def unknown_command
  puts I18n.t :unknown_command
end

.winObject



73
74
75
# File 'lib/console_app/output.rb', line 73

def win
  puts I18n.t :win
end