diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2009-08-01 16:23:35 -0700 | 
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2009-08-01 16:23:35 -0700 | 
| commit | af6101f5e39310445e831554a62c449148476e01 (patch) | |
| tree | 541d8129a2bf9c60e6c432f348b996c12c25a0c3 | |
| parent | 3299b865f3876030cd4b34fa364fad0a64504baf (diff) | |
| download | ruby-libmpd-af6101f5e39310445e831554a62c449148476e01.tar.gz ruby-libmpd-af6101f5e39310445e831554a62c449148476e01.tar.xz | |
Add a new directories method to database methods.
| -rw-r--r-- | libmpd/database.rb | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/libmpd/database.rb b/libmpd/database.rb index 00cc693..4f08f5c 100644 --- a/libmpd/database.rb +++ b/libmpd/database.rb @@ -11,6 +11,21 @@  # Collection of methods related to the database.  module MPDDatabase +  # Returns all directories. +  # If an argument is specified, list all subdirectories of that directory. +  def directories(uri=nil) +    command = 'listall' +    command << ' "%s"' % uri if uri + +    if uri +      path = Regexp.escape(uri + '/') +    else +      path = String.new +    end + +    return send_request(command).scan(/^directory: #{path}([^\/]+)\n/).flatten +  end +    # Counts the number of songs in the database where _field_ is _value_, as    # well as their total playtime.    def count(field, value) | 
