Class: Cliptic::Terminal::Reset_Stats
- Inherits:
-
Object
- Object
- Cliptic::Terminal::Reset_Stats
- Defined in:
- lib/cliptic/terminal.rb
Class Method Summary collapse
- .confirm_reset(table) ⇒ Object
- .prompt(table) ⇒ Object
- .reset(table) ⇒ Object
- .route ⇒ Object
- .user_confirmed? ⇒ Boolean
- .valid_options ⇒ Object
Class Method Details
.confirm_reset(table) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/cliptic/terminal.rb', line 50 def self.confirm_reset(table) puts prompt(table) user_confirmed? ? reset(table) : puts("Wise choice") end |
.prompt(table) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/cliptic/terminal.rb', line 56 def self.prompt(table) <<~prompt cliptic: Reset #{table} Are you sure? This cannot be undone! [Y/n] prompt end |
.reset(table) ⇒ Object
65 66 67 68 69 |
# File 'lib/cliptic/terminal.rb', line 65 def self.reset(table) table == "all" ? Database::Delete.all : Database::Delete.table(table) end |
.route ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/cliptic/terminal.rb', line 39 def self.route if .include?(c = ARGV.shift) ->{confirm_reset(c)} else ->{puts "Unknown option #{c}"} end end |
.user_confirmed? ⇒ Boolean
62 63 64 |
# File 'lib/cliptic/terminal.rb', line 62 def self.user_confirmed? gets.chomp === "Y" end |
.valid_options ⇒ Object
47 48 49 |
# File 'lib/cliptic/terminal.rb', line 47 def self. ["scores", "all", "states", "recents"] end |