summaryrefslogtreecommitdiff
path: root/mpdlib.rb
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2009-07-21 18:58:08 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2009-07-21 18:58:08 -0700
commitd4f3afb5b966430ccff4030833435cd3ad499df5 (patch)
tree9ea2fedd26055874c61a2e973ba676828d140904 /mpdlib.rb
parent2e332839c0830cad3c853c404a9be7efa8ccc249 (diff)
downloadruby-libmpd-d4f3afb5b966430ccff4030833435cd3ad499df5.tar.gz
ruby-libmpd-d4f3afb5b966430ccff4030833435cd3ad499df5.tar.xz
Remove redundant code with split_and_hash method.
Diffstat (limited to 'mpdlib.rb')
-rw-r--r--mpdlib.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/mpdlib.rb b/mpdlib.rb
index 70eb016..12d2d3d 100644
--- a/mpdlib.rb
+++ b/mpdlib.rb
@@ -102,13 +102,24 @@ class MPD
return send_request 'clear'
end
- # Not yet complete.
- def playlistinfo
- playlist = send_request 'playlistinfo'
- playlist = playlist.split(/(?!\n)(?=file:)/).map do |song|
+ def split_and_hash str
+ songs = str.split(/(?!\n)(?=file:)/).map do |song|
generate_hash song
end
- return playlist
+ return songs
+ end
+
+ # Not yet complete.
+ def playlistinfo
+ return split_and_hash send_request 'playlistinfo'
+ end
+
+ def find type, what
+ return split_and_hash send_request 'find %s "%s"' % [type, what]
+ end
+
+ def search type, what
+ return split_and_hash send_request 'search %s "%s"' % [type, what]
end
end