Class: SeClimbingVideos::CLI
- Inherits:
-
Object
- Object
- SeClimbingVideos::CLI
- Defined in:
- lib/se_climbing_videos/cli.rb
Constant Summary collapse
- SEARCH_LINKS =
{ "1" => { location: "Boone, NC", link: "https://www.youtube.com/results?sp=CAI%253D&q=Boone+NC+bouldering" }, "2" => { location: "Grayson Highlands, VA", link: "https://www.youtube.com/results?q=Grayson+Highlands+bouldering&sp=CAI%253D" }, "3" => { location: "Horse Pens 40, AL", link: "https://www.youtube.com/results?q=horse+pens+40+bouldering&sp=CAI%253D" }, "4" => { location: "Rocktown, GA", link: "https://www.youtube.com/results?q=Rocktown+bouldering&sp=CAI%253D" }, "5" => { location: "Rumbling Bald, NC", link: "https://www.youtube.com/results?q=rumbling+bald+bouldering&sp=CAI%253D" }, "6" => { location: "Stone Fort (LRC), TN", link: "https://www.youtube.com/results?sp=CAI%253D&q=Stone+Fort+LRC+bouldering" } }
Instance Attribute Summary collapse
-
#location_input ⇒ Object
Returns the value of attribute location_input.
Instance Method Summary collapse
- #call ⇒ Object
- #display_video(video) ⇒ Object
- #goodbye ⇒ Object
- #location_search ⇒ Object
- #print_videos ⇒ Object
- #select_new_location ⇒ Object
- #select_new_video ⇒ Object
- #select_video ⇒ Object
- #start ⇒ Object
Instance Attribute Details
#location_input ⇒ Object
Returns the value of attribute location_input.
30 31 32 |
# File 'lib/se_climbing_videos/cli.rb', line 30 def location_input @location_input end |
Instance Method Details
#call ⇒ Object
32 33 34 35 36 37 |
# File 'lib/se_climbing_videos/cli.rb', line 32 def call puts "" puts "Welcome to SE Climbing Videos. This is a way to find the newest videos uploaded on Youtube for your favorite Southeast Bouldering spot.".colorize(:light_cyan) puts "" start end |
#display_video(video) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/se_climbing_videos/cli.rb', line 97 def display_video(video) puts "" puts "Video Name:".colorize(:light_blue)+" #{video.name}" puts "" puts "Location:".colorize(:light_blue)+" #{video.location}" puts "Upload Date:".colorize(:light_blue)+" #{video.upload_date}" puts "Uploaded By:".colorize(:light_blue)+" #{video.upload_user}" puts "Duration:".colorize(:light_blue)+" #{video.duration}" puts "Video URL:".colorize(:light_blue)+" #{video.video_url}" puts "" puts "Description:".colorize(:light_blue) puts "#{video.description}" puts "" end |
#goodbye ⇒ Object
149 150 151 |
# File 'lib/se_climbing_videos/cli.rb', line 149 def goodbye puts "Come back soon to see the newest climbing videos for your favorite area!".colorize(:light_cyan) end |
#location_search ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/se_climbing_videos/cli.rb', line 48 def location_search puts "Please enter the number of the bouldering area you would like to search:".colorize(:cyan) puts "You can enter:".colorize(:cyan) puts "1. Boone, NC" puts "2. Grayson Highlands, VA" puts "3. Horse Pens 40, AL" puts "4. Rocktown, GA" puts "5. Rumbling Bald, NC" puts "6. Stone Fort (LRC), TN" self.location_input = gets.strip if ["1", "2", "3", "4", "5", "6"].include?(@location_input) SeClimbingVideos::Scraper.new.make_videos(SeClimbingVideos::CLI::SEARCH_LINKS[@location_input][:link], SeClimbingVideos::CLI::SEARCH_LINKS[@location_input][:location]) elsif @location_input =="exit" goodbye exit else puts "Please enter a valid number. If you don't see your favorite location, send me an email so I can update the app!".colorize(:yellow) location_search end end |
#print_videos ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/se_climbing_videos/cli.rb', line 71 def print_videos puts "---Latest 20 videos from #{SeClimbingVideos::CLI::SEARCH_LINKS[@location_input][:location]}---".colorize(:light_blue) puts "" SeClimbingVideos::Video.all.each.with_index(1) do |video, i| if video.location == SeClimbingVideos::CLI::SEARCH_LINKS[@location_input][:location] puts "#{i}. "+"#{video.name}".colorize(:light_blue)+" - #{video.upload_user} - #{video.upload_date}" end end end |
#select_new_location ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/se_climbing_videos/cli.rb', line 130 def select_new_location puts "Would you like to search for videos in a different location? (Y/N)".colorize(:cyan) input = gets.strip.downcase case input when "y" SeClimbingVideos::Video.reset start when "n" goodbye exit when "exit" goodbye exit else puts "Please enter Y to search more videos or N to exit".colorize(:yellow) select_new_location end end |
#select_new_video ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/se_climbing_videos/cli.rb', line 112 def select_new_video puts "Would you like to select another video from the list? (Y/N)".colorize(:cyan) input = gets.strip.downcase case input when "y" select_video select_new_video when "n" select_new_location when "exit" goodbye exit else puts "Please enter Y to search more videos or N to exit".colorize(:yellow) select_new_video end end |
#select_video ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/se_climbing_videos/cli.rb', line 81 def select_video puts "" puts "Please select which video from the list you would like to learn more about:".colorize(:cyan) video_input = gets.strip if video_input.to_i > 0 and video_input.to_i < 21 video = SeClimbingVideos::Video.find(video_input) display_video(video) elsif video_input == "exit" select_new_location else puts "Not sure which video you want to see more about. Type a number from the list or exit.".colorize(:yellow) select_video end end |
#start ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/se_climbing_videos/cli.rb', line 39 def start location_search print_videos select_video select_new_video select_new_location goodbye end |