Module: Nehm::PlaylistManager

Defined in:
lib/nehm/playlist_manager.rb

Class Method Summary collapse

Class Method Details

.default_user_playlistObject



39
40
41
# File 'lib/nehm/playlist_manager.rb', line 39

def default_user_playlist
  Playlist.new(Cfg[:playlist]) unless Cfg[:playlist].nil?
end

.music_master_libraryObject



43
44
45
# File 'lib/nehm/playlist_manager.rb', line 43

def music_master_library
  Playlist.new(AppleScript.music_master_library)
end

.playlistObject



3
4
5
# File 'lib/nehm/playlist_manager.rb', line 3

def self.playlist
  @temp_playlist || default_user_playlist || music_master_library unless OS.linux?
end

.set_playlistObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nehm/playlist_manager.rb', line 7

def self.set_playlist
  loop do
    playlist = HighLine.new.ask('Enter name of default iTunes playlist to which you want add tracks (press Enter to set it to default iTunes Music library)')

    # If entered nothing, unset iTunes playlist
    if playlist == ''
      Cfg[:playlist] = nil
      puts Paint['Default iTunes playlist unset', :green]
      break
    end

    if AppleScript.list_of_playlists.include? playlist
      Cfg[:playlist] = playlist
      puts Paint["Default iTunes playlist set up to #{playlist}", :green]
      break
    else
      puts Paint['Invalid playlist name. Please enter correct name', :red]
    end
  end
end

.temp_playlist=(playlist) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/nehm/playlist_manager.rb', line 28

def self.temp_playlist=(playlist)
  if AppleScript.list_of_playlists.include? playlist
    @temp_playlist = Playlist.new(playlist)
  else
    puts Paint['Invalid playlist name. Please enter correct name', :red]
    exit
  end
end