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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/audio_addict/commands/log.rb', line 51
def browse_command
tree = log.tree
say ''
network = prompt.select 'Network:', tree.keys, symbols: { marker: '>' }, filter: true, per_page: 10
channel = prompt.select 'Channel:', tree[network].keys, symbols: { marker: '>' }, filter: true,
per_page: page_size
artist = prompt.select 'Artist:', tree[network][channel].keys, symbols: { marker: '>' }, filter: true,
per_page: page_size
say 'Songs:'
tree[network][channel][artist].each { |song| say "- g`#{song}`" }
say ''
browse_command if prompt.yes?('Again?')
end
|
#show_command ⇒ Object
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_command ⇒ Object
45
46
47
48
49
|
# File 'lib/audio_addict/commands/log.rb', line 45
def sort_command
needs :like_log
log.sort
say 'g`Sorted`'
end
|
#tail_command ⇒ Object
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..]
end
|
#tree_command ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/audio_addict/commands/log.rb', line 68
def tree_command
yaml = log.tree.to_yaml
filename = args['--save']
if filename
File.write filename, yaml
say "g`Saved #{filename}`"
else
puts yaml
end
end
|