Class: Output::Messages
- Inherits:
-
Object
- Object
- Output::Messages
- Defined in:
- lib/console_app/output.rb
Constant Summary collapse
- ARROW =
'~> '.freeze
Class Method Summary collapse
- .clear ⇒ Object
- .difficult_error ⇒ Object
- .game_commands ⇒ Object
- .get_hint(game) ⇒ Object
- .hint_error ⇒ Object
- .lose ⇒ Object
- .name_error ⇒ Object
- .save_stats ⇒ Object
- .show_bye ⇒ Object
- .show_difficult ⇒ Object
- .show_game_info(game) ⇒ Object
- .show_greeting ⇒ Object
- .show_name ⇒ Object
- .show_rules ⇒ Object
- .show_stats(stat) ⇒ Object
- .start_again ⇒ Object
- .stats_error ⇒ Object
- .unknown_command ⇒ Object
- .win ⇒ Object
Class Method Details
.clear ⇒ Object
6 7 8 |
# File 'lib/console_app/output.rb', line 6 def clear system('clear') end |
.difficult_error ⇒ Object
90 91 92 |
# File 'lib/console_app/output.rb', line 90 def difficult_error puts I18n.t :difficult_error end |
.game_commands ⇒ Object
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_error ⇒ Object
94 95 96 |
# File 'lib/console_app/output.rb', line 94 def hint_error puts I18n.t :hint_error end |
.lose ⇒ Object
86 87 88 |
# File 'lib/console_app/output.rb', line 86 def lose puts I18n.t :lose end |
.name_error ⇒ Object
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_stats ⇒ Object
77 78 79 80 |
# File 'lib/console_app/output.rb', line 77 def save_stats puts I18n.t :save_stats print ARROW end |
.show_bye ⇒ Object
35 36 37 |
# File 'lib/console_app/output.rb', line 35 def show_bye puts I18n.t :goodbye end |
.show_difficult ⇒ Object
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_greeting ⇒ Object
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_name ⇒ Object
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_rules ⇒ Object
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_again ⇒ Object
68 69 70 71 |
# File 'lib/console_app/output.rb', line 68 def start_again puts I18n.t :start_again print ARROW end |
.stats_error ⇒ Object
10 11 12 |
# File 'lib/console_app/output.rb', line 10 def stats_error puts I18n.t :stats_error end |
.unknown_command ⇒ Object
98 99 100 |
# File 'lib/console_app/output.rb', line 98 def unknown_command puts I18n.t :unknown_command end |
.win ⇒ Object
73 74 75 |
# File 'lib/console_app/output.rb', line 73 def win puts I18n.t :win end |