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



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

def generate_command(name = nil)
  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_commandObject



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

def init_command
  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
  end
end