Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantiate a playlist by name #52

Open
Phrogz opened this issue Jan 8, 2016 · 0 comments
Open

Instantiate a playlist by name #52

Phrogz opened this issue Jan 8, 2016 · 0 comments

Comments

@Phrogz
Copy link
Contributor

Phrogz commented Jan 8, 2016

My UI uses the name of a playlist as the unique identifier. When I want to fetch a playlist with this name I must currently use one of the following:

playlist = @mpd.playlists.find{ |pl| pl.name==playlistname }
playlist = MPD::Playlist.new( @mpd, playlist:playlistname )

Using find feels gross because it instantiates all the playlists (maybe a great many) when I only need one. Using new feels gross because if I mistakenly ask for a playlist that does not exist it will be created.

I'd prefer to be able to do something like:

playlist = @mpd.playlist( playlistname )

Does that seem reasonable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant