Class: NewOpportunities::CLI
- Inherits:
-
Object
- Object
- NewOpportunities::CLI
- Defined in:
- lib/new-opportunities/cli.rb
Overview
CLI Controller
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/new-opportunities/cli.rb', line 5 def call NewOpportunities::Opportunities.scrape puts "Scholarship and fellowship opportunities from http://oppourtunities.com" list_opportunities goodbye end |
#goodbye ⇒ Object
45 46 47 |
# File 'lib/new-opportunities/cli.rb', line 45 def goodbye puts "see you soon for more opportunities." end |
#list_opportunities ⇒ Object
13 14 15 16 17 18 |
# File 'lib/new-opportunities/cli.rb', line 13 def list_opportunities @opportunities = NewOpportunities::Opportunities.all @opportunities.each.with_index(1) do |opportunity, i| puts "#{i}. #{opportunity.name}" end end |
#menu ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/new-opportunities/cli.rb', line 20 def input = nil while input != 'exit' puts "Enter the number of the opportunity you'd like more info on, or type list, or type exit " input = gets.strip.downcase if input.to_i >0 the_opportunity = @opportunities[input.to_i - 1] puts "#{the_opportunity.name} \nDeadline: #{the_opportunity.deadline} \nPosted on: #{the_opportunity.post_date}" puts "type more to see the description or type url to find the link" input_2 = gets.strip.downcase if input_2 == "more" puts "#{the_opportunity.description}" elsif input_2 == "url" puts "#{the_opportunity.url}" puts "" end elsif input == "list" list_opportunities else puts "not sure what you want, type list or exit" end end end |