class SeClimbingVideos::CLI

Constants

Attributes

location_input[RW]

Public Instance Methods

call() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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
print_videos() click to toggle source
select_new_location() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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