Class: DanceTime::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/dance_time/cli.rb

Instance Method Summary collapse

Instance Method Details

#callObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/dance_time/cli.rb', line 3

def call
  puts ""
  puts "Welcome to the Best YouTube Dance Channels!"
  puts ""
  puts "Type list to see our list of channels"
  input = gets.strip.downcase
  if input == "list"
    DanceTime::Scraper.new.make_channels
    start
  else
    call
  end
end

#channel_listObject



39
40
41
42
43
# File 'lib/dance_time/cli.rb', line 39

def channel_list
  DanceTime::Channel.all.each.with_index(1) do |channel, i|
    puts "#{i}. #{channel.name}"
  end
end

#channel_profile(channel) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/dance_time/cli.rb', line 45

def channel_profile(channel)
  puts ""
  puts "~~~#{channel.name} Profile: ~~~"
  puts ""
  puts "About: #{channel.about}"
  puts "YouTube Link: #{channel.youtube_link}"
  puts "Frequency: #{channel.frequency.gsub(/^Frequency - /, "")}"
  puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
end

#startObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dance_time/cli.rb', line 17

def start
  channel_list
  puts "Here's a list of channels, scroll up to see the full list."
  puts "Type the number of the channel you'd like more info on."
  input = gets.strip.to_i
  channel = DanceTime::Channel.find(input)
  channel_profile(channel)
  puts "Would you like to see more? y/n"
  input = gets.strip.downcase

  if input == "y" || input == "yes"
    start
  elsif input == "n" || input == "exit"
    puts "Thanks for playing. Goodbye!"
    exit
  else
    puts "Please try again"
    sleep 3
    start
  end
end