class TopGeniusSongs::CLI

Public Instance Methods

call() click to toggle source
# File lib/top_genius_songs/cli.rb, line 2
def call
        start
end
help() click to toggle source
# File lib/top_genius_songs/cli.rb, line 29
def help
        puts "Type 'list' to list songs, or any number of the song for the lyrics!"
        print ">>  "
end
list() click to toggle source
# File lib/top_genius_songs/cli.rb, line 34
def list
        puts "Songs:"
        TopGeniusSongs::Song.all.each.with_index(1) do |song, index|
                puts "#{index}. \"#{song.title}\" By \"#{song.artist}\""
                print "Description:"
                puts "#{song.description[0..300]}..."
                puts '     -----------------------------         '
                puts ''
        end
end
start() click to toggle source
# File lib/top_genius_songs/cli.rb, line 6
def start
        puts "Hi Welcome to Top Genius Songs!!"
        sleep(1)
        songs = TopGeniusSongs::Scraper.scrape
        list
        input = nil
        help
        while input != 'exit'
                input = gets.chomp
                if input == 'list'
                        list
                elsif input.to_i > 0 && input.to_i <= songs.size
                        puts "------------ '#{songs[input.to_i-1].title}' Lyrics --------------- "
                        sleep(1)
                        puts "#{songs[input.to_i-1].lyrics}"
                        print ">>  "
                else
                        help
                end
        end
        puts "Genius!!!!! we rule!"
end