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(args) ⇒ Object



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

def generate_command(args)
  needs :network, :channel, :listen_key

  

  name = args['NAME']

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

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

#init_command(args) ⇒ Object



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

def init_command(args)
  needs :network, :channel, :listen_key

  

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

  say "!txtred!Warning!txtrst!: !txtgrn!#{outfile}!txtrst! already exists!" if File.exist? outfile
  proceed = prompt.yes? "Create #{outfile}?"
  if proceed
    generate_config outfile
    say ""
    generate_command({ 'NAME' => name }) # we also generate the playlist
  end
end