Class: AudioAddict::Commands::PlaylistCmd

Inherits:
Base
  • Object
show all
Defined in:
lib/audio_addict/commands/playlist.rb

Instance Method Summary collapse

Methods inherited from Base

#current_channel, #current_network, #needs, #prompt, #radio, #require_premium_account

Instance Method Details

#generate_command(name = nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/audio_addict/commands/playlist.rb', line 38

def generate_command(name = nil)
  needs :network, :channel, :listen_key

  

  name ||= args['NAME']

  infile = "#{name}.yml"
  outfile = "#{name}.pls"

  if File.exist? infile
    say "r`Warning`: g`#{outfile}` already exists!" if File.exist? outfile
    proceed = prompt.yes? "Create #{outfile}?"
    generate_playlist infile, outfile if proceed
  else
    say "r`Cannot find #{infile}`"
  end
end

#init_commandObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/audio_addict/commands/playlist.rb', line 21

def init_command
  needs :network, :channel, :listen_key

  

  name = args['NAME']
  outfile = "#{name}.yml"

  say "r`Warningr`: g`#{outfile}` already exists!" if File.exist? outfile
  proceed = prompt.yes? "Create #{outfile}?"
  return unless proceed

  generate_config outfile
  say ''
  generate_command name
end