Class: AudioAddict::Commands::LogCmd
- Inherits:
-
Base
- Object
- MisterBin::Command
- Base
- AudioAddict::Commands::LogCmd
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_command ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/audio_addict/commands/log.rb', line 49
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_command ⇒ Object
31
32
33
34
35
|
# File 'lib/audio_addict/commands/log.rb', line 31
def show_command
needs :like_log
query = args['SEARCH']
puts query ? log.search(query) : log.data
end
|
#sort_command ⇒ Object
43
44
45
46
47
|
# File 'lib/audio_addict/commands/log.rb', line 43
def sort_command
needs :like_log
log.sort
say "!txtgrn!Sorted"
end
|
#tail_command ⇒ Object
37
38
39
40
41
|
# File 'lib/audio_addict/commands/log.rb', line 37
def tail_command
needs :like_log
lines = args['--lines'].to_i
puts log.data[-lines..-1]
end
|
#tree_command ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/audio_addict/commands/log.rb', line 64
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
|