diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2009-07-21 18:58:08 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2009-07-21 18:58:08 -0700 |
commit | d4f3afb5b966430ccff4030833435cd3ad499df5 (patch) | |
tree | 9ea2fedd26055874c61a2e973ba676828d140904 | |
parent | 2e332839c0830cad3c853c404a9be7efa8ccc249 (diff) | |
download | ruby-libmpd-d4f3afb5b966430ccff4030833435cd3ad499df5.tar.gz ruby-libmpd-d4f3afb5b966430ccff4030833435cd3ad499df5.tar.xz |
Remove redundant code with split_and_hash method.
-rw-r--r-- | mpdlib.rb | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -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 |