Class: AudioAddict::Commands::LogCmd

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

Instance Method Summary collapse

Methods inherited from Base

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

Instance Method Details

#browse_commandObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/audio_addict/commands/log.rb', line 51

def browse_command
  tree = log.tree

  say ""
  network = prompt.select "Network:", tree.keys, marker: '>', filter: true
  channel = prompt.select "Channel:", tree[network].keys, marker: '>', filter: true, per_page: page_size
  artist  = prompt.select "Artist:",  tree[network][channel].keys, marker: '>', filter: true, per_page: page_size
  
  say "Songs:"
  tree[network][channel][artist].each { |song| say "- !txtgrn!#{song}" }
  say ""

  browse_command if prompt.yes?("Again?")
end

#show_commandObject



33
34
35
36
37
# File 'lib/audio_addict/commands/log.rb', line 33

def show_command
  needs :like_log
  query = args['SEARCH']
  puts query ? log.search(query) : log.data
end

#sort_commandObject



45
46
47
48
49
# File 'lib/audio_addict/commands/log.rb', line 45

def sort_command
  needs :like_log
  log.sort
  say "!txtgrn!Sorted"
end

#tail_commandObject



39
40
41
42
43
# File 'lib/audio_addict/commands/log.rb', line 39

def tail_command
  needs :like_log
  lines = args['--lines'].to_i
  puts log.data[-lines..-1]
end

#tree_commandObject



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/audio_addict/commands/log.rb', line 66

def tree_command
  yaml = log.tree.to_yaml
  filename = args['--save']
  
  if filename
    File.write filename, yaml
    say "!txtgrn!Saved #{filename}"
  else
    puts yaml
  end
end