Class: Cliptic::Terminal::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/cliptic/terminal.rb

Class Method Summary collapse

Class Method Details

.closeObject



33
34
35
36
# File 'lib/cliptic/terminal.rb', line 33

def self.close
  Curses.close_screen
  puts "Thanks for playing!"
end


18
19
20
21
# File 'lib/cliptic/terminal.rb', line 18

def self.main_menu
  setup
  Cliptic::Menus::Main.new.choose_opt
end

.parse_argsObject



22
23
24
25
26
27
# File 'lib/cliptic/terminal.rb', line 22

def self.parse_args
  case arg = ARGV.shift
  when "reset", "-r" then Reset_Stats.route.call
  when "today", "-t" then play(ARGV.shift.to_i)
  end
end

.play(offset) ⇒ Object



28
29
30
31
32
# File 'lib/cliptic/terminal.rb', line 28

def self.play(offset)
  setup
  Cliptic::Main::Player::
    Game.new(date:Date.today+offset).play
end

.runObject



4
5
6
7
8
9
10
# File 'lib/cliptic/terminal.rb', line 4

def self.run
  ARGV.size > 0 ?
    parse_args : main_menu
  rescue StandardError => e
    Curses.close_screen
    abort(e.message)
end

.setupObject



12
13
14
15
16
17
# File 'lib/cliptic/terminal.rb', line 12

def self.setup
  Config::Default.set
  Screen.setup
  Config::Custom.set
  at_exit{close}
end