Class: Mixtape::CLI

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

Defined Under Namespace

Classes: InvalidSource

Instance Method Summary collapse

Constructor Details

#initialize(source_name, number_of_songs) ⇒ CLI

Returns a new instance of CLI.



5
6
7
8
9
10
# File 'lib/mixtape/cli.rb', line 5

def initialize(source_name, number_of_songs)
  source_constant = Mixtape::Source.const_get(source_name.capitalize)
  @source = source_constant.new(number_of_songs)
  @source_name = source_name
  rescue NameError; raise InvalidSource
end

Instance Method Details

#open_playlistObject



12
13
14
15
16
17
18
19
# File 'lib/mixtape/cli.rb', line 12

def open_playlist
  system "echo 'Creating mixtape...'"
  playlist =  Mixtape::YoutubePlaylist.new(@source.songs)
  launch = Thread.new { Launchy.open(playlist.url) }
  mixtape_animation = Thread.new { awesome_output }
  mixtape_animation.join
  launch.join
end