From 890476e7e2452e359d8c528348dc4f30c3dfb797 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Fri, 24 Jul 2009 11:00:20 -0700 Subject: New update method and improved database docs. --- libmpd/database.rb | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'libmpd/database.rb') diff --git a/libmpd/database.rb b/libmpd/database.rb index a1a6660..3f5616e 100644 --- a/libmpd/database.rb +++ b/libmpd/database.rb @@ -5,13 +5,28 @@ # See http://www.gnu.org/licenses/gpl.txt for the full license text. module MPDDatabase - # Find all songs in database with an exact match. - def find type, what - return split_and_hash send_request 'find %s "%s"' % [type, what] + # Finds all songs in the database where _field_ is _value_. + # Matching is case-sensitive. + # + # Possible field names: album, artist, title. + def find field, value + return split_and_hash send_request 'find %s "%s"' % [field, value] end - # Searches the database. - def search type, what - return split_and_hash send_request 'search %s "%s"' % [type, what] + # Finds all songs in the database where _field_ contains _value_. + # Matching is not case-sensitive. + # + # Possible field names: album, artist, filename, title. + def search field, value + return split_and_hash send_request 'search %s "%s"' % [field, value] + end + + # Updates the database. + # If an argument is given, update that particular file or directory. + def update uri=nil + command = 'update' + command << ' "%s"' % uri if uri + + return send_request command end end -- cgit v1.2.3-70-g09d2