Class: DigitalNomadJobs::CLI
- Inherits:
-
Object
- Object
- DigitalNomadJobs::CLI
- Defined in:
- lib/digital_nomad_jobs/cli.rb
Constant Summary collapse
- PATH =
('https://remoteok.io')
Instance Method Summary collapse
- #add_descriptions_to_jobs ⇒ Object
- #call ⇒ Object
-
#display_companies ⇒ Object
——————————– CLI DISPLAY METHODS —————————–#.
- #display_jobs ⇒ Object
- #error ⇒ Object
- #list_menu ⇒ Object
- #main_menu ⇒ Object
- #make_all_the_jobs ⇒ Object
- #make_design_jobs ⇒ Object
-
#make_dev_jobs ⇒ Object
———————————— CLI JOB FACTORY ————————————–#.
- #navigation ⇒ Object
- #select_company ⇒ Object
- #select_job ⇒ Object
-
#select_job_maker ⇒ Object
———————————- CLI INPUT SELECTORS ———————————-#.
- #valid_company?(input) ⇒ Boolean
- #valid_job?(input) ⇒ Boolean
-
#welcome ⇒ Object
———————————- CLI MENUS ———————————-#.
Instance Method Details
#add_descriptions_to_jobs ⇒ Object
197 198 199 200 201 202 |
# File 'lib/digital_nomad_jobs/cli.rb', line 197 def add_descriptions_to_jobs DigitalNomadJobs::Job.all.each do |job| description_hash = DigitalNomadJobs::Scraper.scrape_descriptions(PATH + job.job_url) job.add_job_description(description_hash) end end |
#call ⇒ Object
5 6 7 8 |
# File 'lib/digital_nomad_jobs/cli.rb', line 5 def call welcome end |
#display_companies ⇒ Object
——————————– CLI DISPLAY METHODS —————————–#
206 207 208 209 |
# File 'lib/digital_nomad_jobs/cli.rb', line 206 def display_companies DigitalNomadJobs::Company.list_companies select_company end |
#display_jobs ⇒ Object
212 213 214 215 |
# File 'lib/digital_nomad_jobs/cli.rb', line 212 def display_jobs DigitalNomadJobs::Job.list_all_jobs select_job end |
#error ⇒ Object
150 151 152 |
# File 'lib/digital_nomad_jobs/cli.rb', line 150 def error puts 'Whoops! Please Enter A Valid Option.'.magenta end |
#list_menu ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/digital_nomad_jobs/cli.rb', line 36 def puts "=========== LIST MENU ===================".blue puts "" puts "Enter '1' For A List of The Most Recent Job Postings" puts "Enter '2' For A List of The Companies Hiring" puts "Enter '0' To Exit" puts "Enter 'Main' To Go Back To The Main Menu" puts "================================================".blue user_input = gets.strip.to_s case user_input when '1' display_jobs when '2' display_companies when 'Main', 'main' when '0', 'exit' puts "Thanks for Visiting!" exit else error end end |
#main_menu ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/digital_nomad_jobs/cli.rb', line 20 def puts "" puts "======== 🌎 MAIN MENU 🌎 ===========".blue puts " ".blue puts " What Are You Looking For?".blue puts "" puts "Enter '1' for The Latest Web Developer Jobs" puts "Enter '2' for The Latest UX/UI & Web Design Jobs" puts "Enter '3' for The Latest Remote Jobs" puts "Enter '0' or type 'exit' to exit" puts "" puts "========= x x x x x x x =============".blue select_job_maker end |
#make_all_the_jobs ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/digital_nomad_jobs/cli.rb', line 183 def make_all_the_jobs DigitalNomadJobs::Job.reset DigitalNomadJobs::Company.reset job_array = DigitalNomadJobs::Scraper.scrape_jobs(PATH) DigitalNomadJobs::Job.create_from_collection(job_array) puts "" puts " 🌎 " puts "------------------------------------------------".blue puts " NABBING THE NEWEST REMOTE JOBS ".white.on_blue add_descriptions_to_jobs end |
#make_design_jobs ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/digital_nomad_jobs/cli.rb', line 169 def make_design_jobs DigitalNomadJobs::Job.reset DigitalNomadJobs::Company.reset job_array = DigitalNomadJobs::Scraper.scrape_jobs(PATH + '/remote-design-jobs') DigitalNomadJobs::Job.create_from_collection(job_array) puts "" puts " 🎨 " puts "------------------------------------------------".blue puts " LOADING WEB DESIGN JOBS ".white.on_blue add_descriptions_to_jobs end |
#make_dev_jobs ⇒ Object
———————————— CLI JOB FACTORY ————————————–#
155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/digital_nomad_jobs/cli.rb', line 155 def make_dev_jobs DigitalNomadJobs::Job.reset DigitalNomadJobs::Company.reset job_array = DigitalNomadJobs::Scraper.scrape_jobs(PATH + '/remote-dev-jobs') DigitalNomadJobs::Job.create_from_collection(job_array) puts "" puts ' 🖥️ ' puts "------------------------------------------------".blue puts " NABBING WEB DEVELOPER JOBS ".white.on_blue add_descriptions_to_jobs end |
#navigation ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/digital_nomad_jobs/cli.rb', line 63 def puts "" puts "======== NAVIGATION ===========".blue puts " Where Ya Headed Now?".blue puts "" puts "Enter 'Main' to go Back to the Main Menu" puts "Enter 'List' To Go Back to the List Menu" puts "Enter 'Exit' to Exit." puts "========= x x x x x x x =============".blue puts "" input = gets.strip.to_s case input when 'main', 'Main' when 'list', 'List' when 'exit', 'Exit' exit else puts 'Not All Those Who Wander Are Lost... But You Might Be!'.cyan error end end |
#select_company ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/digital_nomad_jobs/cli.rb', line 110 def select_company puts "" puts "Enter The Number of A Company To See It's Recent Job Posts" cn = gets.strip.to_i if valid_company?(cn) comp = DigitalNomadJobs::Company.all[cn-1] comp.print_company_jobs else error select_company end end |
#select_job ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/digital_nomad_jobs/cli.rb', line 135 def select_job puts "" puts "Enter The Number of a Job Post For a Detailed Description" jp = gets.strip.to_i if valid_job?(jp) job = DigitalNomadJobs::Job.all[jp - 1] job.print_job_description else error select_job end end |
#select_job_maker ⇒ Object
———————————- CLI INPUT SELECTORS ———————————-#
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/digital_nomad_jobs/cli.rb', line 91 def select_job_maker input = gets.strip.to_s case input when '1' make_dev_jobs when '2' make_design_jobs when '3' make_all_the_jobs when '0','exit' puts "Bye!".blue exit else puts "Whoops! Please enter a valid option.".magenta end end |
#valid_company?(input) ⇒ Boolean
125 126 127 |
# File 'lib/digital_nomad_jobs/cli.rb', line 125 def valid_company?(input) input.between?(1, DigitalNomadJobs::Company.all.size) end |
#valid_job?(input) ⇒ Boolean
130 131 132 |
# File 'lib/digital_nomad_jobs/cli.rb', line 130 def valid_job?(input) input.between?(1, DigitalNomadJobs::Job.all.size) end |
#welcome ⇒ Object
———————————- CLI MENUS ———————————-#
12 13 14 15 16 17 |
# File 'lib/digital_nomad_jobs/cli.rb', line 12 def welcome puts "================================================".blue puts ") Welcome to DIGITAL NOMAD JOBS! (".blue puts "================================================".blue puts " LET'S EXPLORE ".white.on_blue end |