class Nehm::GetCommand
Constants
- FIRST_TRACK
Public Class Methods
new()
click to toggle source
Calls superclass method
Nehm::Command::new
# File lib/nehm/commands/get_command.rb, line 6 def initialize super add_option(:from, 'from PERMALINK', 'Get track(s) from user with PERMALINK') add_option(:to, 'to PATH', 'Download track(s) to PATH') add_option(:pl, 'pl PLAYLIST', 'Add track(s) to iTunes playlist with PLAYLIST name') end
Public Instance Methods
arguments()
click to toggle source
# File lib/nehm/commands/get_command.rb, line 48 def arguments { 'post' => 'Get last post (track or repost) from your profile', 'NUMBER posts' => 'Get last NUMBER posts from your profile', 'like' => 'Get your last like', 'NUMBER likes' => 'Get your last NUMBER likes', 'URL' => 'Get track from entered URL' } end
execute()
click to toggle source
# File lib/nehm/commands/get_command.rb, line 19 def execute track_manager = TrackManager.new(@options) arg = @options[:args].pop tracks = case arg when /^l.*s$/ count = @options[:args].pop.to_i track_manager.likes(count, 0) when /^p.*s$/ count = @options[:args].pop.to_i track_manager.posts(count, 0) when /^l/ track_manager.likes(*FIRST_TRACK) when /^p/ track_manager.posts(*FIRST_TRACK) when /https:\/\/soundcloud.com\// track_manager.track_from_url(arg) when nil UI.term 'You must provide an argument' else UI.term "Invalid argument/option '#{arg}'" end UI.term 'There are no tracks yet' if tracks.nil? track_manager.process_tracks(tracks) end
program_name()
click to toggle source
# File lib/nehm/commands/get_command.rb, line 56 def program_name 'nehm get' end
summary()
click to toggle source
# File lib/nehm/commands/get_command.rb, line 60 def summary 'Download tracks, set tags and add to your iTunes library tracks from SoundCloud' end
usage()
click to toggle source
# File lib/nehm/commands/get_command.rb, line 64 def usage "#{program_name} ARGUMENT [OPTIONS]" end