Class: AppleMusicLibrary::PlaylistFolder

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_music_library/playlist_folder.rb

Constant Summary collapse

@@playlist_folders =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info) ⇒ PlaylistFolder

Returns a new instance of PlaylistFolder.



10
11
12
13
14
# File 'lib/apple_music_library/playlist_folder.rb', line 10

def initialize(info)
  @info = info

  @@playlist_folders[id] = self
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



6
7
8
# File 'lib/apple_music_library/playlist_folder.rb', line 6

def info
  @info
end

Class Method Details

.allObject



16
17
18
# File 'lib/apple_music_library/playlist_folder.rb', line 16

def self.all
  @@playlist_folders.values
end

.find_by_name(playlist_folder_name) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/apple_music_library/playlist_folder.rb', line 20

def self.find_by_name(playlist_folder_name)
  results = @@playlist_folders.values.select{|pf| pf.name == playlist_folder_name}
  if results.size == 1
    return results.first
  end
  results
end

Instance Method Details

#childrenObject



32
33
34
# File 'lib/apple_music_library/playlist_folder.rb', line 32

def children
  playlist_folders.concat(playlists)
end

#idObject



28
29
30
# File 'lib/apple_music_library/playlist_folder.rb', line 28

def id
  playlist_persistent_id
end

#playlist_foldersObject



36
37
38
# File 'lib/apple_music_library/playlist_folder.rb', line 36

def playlist_folders
  @@playlist_folders.values.select{|pf| pf.parent_persistent_id == id}
end

#playlistsObject



40
41
42
# File 'lib/apple_music_library/playlist_folder.rb', line 40

def playlists
  Playlist.all.select{|p| p.parent_persistent_id == id}
end