Class: CLIInterface
- Inherits:
-
Object
- Object
- CLIInterface
- Defined in:
- lib/cli_interface.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #details_menu_display ⇒ Object
- #details_menu_input ⇒ Object
- #exit_method ⇒ Object
- #is_integer?(details_input) ⇒ Boolean
- #list_shortcuts ⇒ Object
- #main_menu_display ⇒ Object
- #main_menu_input ⇒ Object
- #search_by_os_and_key ⇒ Object
- #search_by_os_and_name ⇒ Object
- #set_os ⇒ Object
- #submenu_display ⇒ Object
- #submenu_input ⇒ Object
- #welcome_greeting ⇒ Object
Class Method Details
.detail_view(key) ⇒ Object
159 160 161 162 163 164 |
# File 'lib/cli_interface.rb', line 159 def self.detail_view(key) puts "\n\n Shortcut Key Sequence: #{key.key_seq}\n" puts " Shortcut Name: #{key.name.capitalize}\n" puts " Operating System: #{key..name}\n" puts " Shortcut Description: #{key.description.capitalize}\n\n" end |
.error ⇒ Object
166 167 168 169 |
# File 'lib/cli_interface.rb', line 166 def self.error puts "Your response was not understood.\n" puts "Please select a valid option.\n" end |
.not_found ⇒ Object
171 172 173 174 |
# File 'lib/cli_interface.rb', line 171 def self.not_found puts "\nYour selection was not found or not understood.\n" puts "Please try a different search term or adjust your format.\n" end |
Instance Method Details
#call ⇒ Object
3 4 5 6 |
# File 'lib/cli_interface.rb', line 3 def call Scraper.new.scrape_atom welcome_greeting end |
#details_menu_display ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/cli_interface.rb', line 124 def puts "To view DETAILS of a specific shortcut enter the number below \n" puts "To return to SEARCH MENU type 'SM'" puts "To return to MAIN MENU type 'MM'\n" puts "To EXIT type 'X'" end |
#details_menu_input ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/cli_interface.rb', line 132 def details_input = gets.strip.upcase if details_input == 'SM' elsif details_input == 'MM' elsif details_input == 'X' exit_method elsif is_integer?(details_input) @os.search_by_number(details_input) else CLIInterface.error end puts "\n" end |
#exit_method ⇒ Object
153 154 155 156 157 |
# File 'lib/cli_interface.rb', line 153 def exit_method puts "\nThanks for using the Atom Shortcuts!" puts "See you again soon!\n\n\n" exit end |
#is_integer?(details_input) ⇒ Boolean
149 150 151 |
# File 'lib/cli_interface.rb', line 149 def is_integer?(details_input) details_input.to_i.to_s == details_input end |
#list_shortcuts ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/cli_interface.rb', line 95 def list_shortcuts puts "\n*************************************" puts "\n ATOM SHORTCUTS FOR #{@os.name} OS" puts "\n*************************************\n\n" @os.sort_alphabetically @os.shortcuts.each_with_index do |shortcut, index| if (index)%10 == 0 && (index) != 0 puts "\n (Press Enter to Continue)\n\n" gets end puts " #{index + 1}. #{shortcut.name}: #{shortcut.key_seq} \n" end puts "\n\n" end |
#main_menu_display ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cli_interface.rb', line 24 def puts"\n*********************************\n" puts "********** MAIN MENU **********\n" puts "*********************************\n\n" puts "Please Select Your Operating System\n" puts "or type 'X' to exit." puts "1. Mac OS\n" puts "2. Windows\n" puts "3. Linux\n" puts "X. EXIT\n\n" end |
#main_menu_input ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cli_interface.rb', line 38 def @user_os = gets.strip.upcase if @user_os == "X" exit_method elsif @user_os == "1" || @user_os =="2" || @user_os =="3" set_os else CLIInterface.error end end |
#search_by_os_and_key ⇒ Object
117 118 119 120 121 122 |
# File 'lib/cli_interface.rb', line 117 def search_by_os_and_key puts "Enter the key you would like to search for: \n" puts "(Use the format 'CTRL-K')\n" key_to_find = gets.strip.upcase @os.search_by_key(key_to_find) end |
#search_by_os_and_name ⇒ Object
110 111 112 113 114 115 |
# File 'lib/cli_interface.rb', line 110 def search_by_os_and_name puts "Enter the shortcut name you would like to search for: \n" puts "(Use the format 'find in project')" name = gets.strip.downcase @os.search_by_name(name) end |
#set_os ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cli_interface.rb', line 84 def set_os if @user_os == "1" @os = OperatingSystem.find_by_name("Mac") elsif @user_os == "2" @os = OperatingSystem.find_by_name("Windows") else @os = OperatingSystem.find_by_name("Linux") end end |
#submenu_display ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cli_interface.rb', line 51 def puts "\nPlease select an option from the Menu Below:\n" puts "To LIST ALL shortcuts for your operating system type 'L'" puts "To search shortcuts by NAME type 'N'" puts "To search shortcuts by KEY type 'K'" puts "To return to MAIN MENU type 'MM'" puts "To EXIT type 'X'" puts "\nEnter your Selection:" end |
#submenu_input ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/cli_interface.rb', line 62 def @user_input = gets.strip.upcase puts "\n" if @user_input == "L" list_shortcuts elsif @user_input == "X" exit_method elsif @user_input == "N" search_by_os_and_name elsif @user_input == "K" search_by_os_and_key elsif @user_input == "MM" else CLIInterface.error end puts "\n" end |
#welcome_greeting ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cli_interface.rb', line 8 def welcome_greeting puts "\n\n\n****** Welcome To - Atom Shortcuts Quick Reference ******\n\n" puts " This is a cli utility gem designed as a quick reference\n" puts " to Atoms many shortcuts. With so many languages, commands,\n" puts " shortcuts and tools to memorize, you can now access a quick\n" puts " digital reference without having to interrupt your workflow.\n" puts " Being familiar with important shortcuts and commands speeds\n" puts " up your workflow and increases your productivity as a programmer.\n" puts "\n\nPress the ENTER key to continue....." any_key = gets if any_key.include?("\n") end end |