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



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

def difficult_error
  puts I18n.t :difficult_error
end

.game_commandsObject



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

def game_commands
  puts I18n.t :game_commands
end

.get_hint(game) ⇒ Object



42
43
44
45
46
# File 'lib/console_app/output.rb', line 42

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

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

.hint_errorObject



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

def hint_error
  puts I18n.t :hint_error
end

.loseObject



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

def lose
  puts I18n.t :lose
end

.name_errorObject



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

def name_error
  puts I18n.t :name_error
end

.save_statsObject



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

def save_stats
  puts I18n.t :save_stats
  print ARROW
end

.show_byeObject



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

def show_bye
  puts I18n.t :goodbye
end

.show_difficultObject



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

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

.show_game_info(game) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/console_app/output.rb', line 34

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



20
21
22
23
24
# File 'lib/console_app/output.rb', line 20

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

.show_nameObject



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

def show_name
  puts I18n.t :set_name
  print ARROW
end

.show_rulesObject



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

def show_rules
  puts I18n.t :rules
end

.show_stats(stat) ⇒ Object



14
15
16
17
18
# 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,
                           a: (stat[:attempts] + stat[:attempts_used]), a_used: stat[:attempts_used],
                           h: (stat[:hints] + stat[:hints_used]), h_used: stat[:hints_used])
end

.start_againObject



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

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



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

def unknown_command
  puts I18n.t :unknown_command
end

.winObject



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

def win
  puts I18n.t :win
end