From a3b7470f0964fbb175aeb32713037ab64831fadb Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Thu, 23 Jul 2009 22:52:59 -0700 Subject: More modularisation with playlist methods. --- libmpd.rb | 17 ++--------------- libmpd/playlist.rb | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 libmpd/playlist.rb diff --git a/libmpd.rb b/libmpd.rb index 13bdf4b..84e1c40 100644 --- a/libmpd.rb +++ b/libmpd.rb @@ -7,6 +7,7 @@ require 'socket' require 'libmpd/playbackcontrol' require 'libmpd/playbackoptions' +require 'libmpd/playlist' require 'libmpd/status' class TrueClass # :nodoc: @@ -24,6 +25,7 @@ end class MPD include MPDPlaybackControl include MPDPlaybackOptions + include MPDPlaylist include MPDStatus # Initialise an MPD object with the specified host and port. @@ -71,21 +73,6 @@ class MPD return hash end - # Adds the specified file to the playlist. (Directories add recursively.) - def add uri - return send_request 'add "%s"' % uri - end - - # Deletes a song from the playlist. - def delete songpos - return send_request 'delete ' + songpos.to_s - end - - # Clears the playlist. - def clear - return send_request 'clear' - end - def split_and_hash str songs = str.split(/(?!\n)(?=file:)/).map do |song| generate_hash song diff --git a/libmpd/playlist.rb b/libmpd/playlist.rb new file mode 100644 index 0000000..9445625 --- /dev/null +++ b/libmpd/playlist.rb @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby +# +# Copyright 2009 David Vazgenovich Shakaryan +# Distributed under the terms of the GNU General Public License v3. +# See http://www.gnu.org/licenses/gpl.txt for the full license text. + +module MPDPlaylist + # Adds the specified file to the playlist. (Directories add recursively.) + def add uri + return send_request 'add "%s"' % uri + end + + # Deletes a song from the playlist. + def delete songpos + return send_request 'delete ' + songpos.to_s + end + + # Clears the playlist. + def clear + return send_request 'clear' + end +end -- cgit v1.2.3-70-g09d2