class AudioAddict::Commands::LogCmd
Public Instance Methods
browse_command()
click to toggle source
# 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 "- !txtgrn!#{song}" } say "" browse_command if prompt.yes?("Again?") end
show_command()
click to toggle source
# 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()
click to toggle source
# File lib/audio_addict/commands/log.rb, line 45 def sort_command needs :like_log log.sort say "!txtgrn!Sorted" end
tail_command()
click to toggle source
# 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_command()
click to toggle source
# 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
Private Instance Methods
log()
click to toggle source
# File lib/audio_addict/commands/log.rb, line 80 def log @log ||= Log.new end
page_size()
click to toggle source
# File lib/audio_addict/commands/log.rb, line 84 def page_size @page_size ||= detect_terminal_size[1] - 4 end