summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2009-07-23 19:29:31 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2009-07-23 19:29:31 -0700
commitcff0409822f20022d82280f2f50305c4b4ebce85 (patch)
treec01001571aa279b37abdf0bf016100916b93f744
parentd3c4f79699a00d32393ae02116404113599f0c6b (diff)
downloadruby-libmpd-cff0409822f20022d82280f2f50305c4b4ebce85.tar.gz
ruby-libmpd-cff0409822f20022d82280f2f50305c4b4ebce85.tar.xz
Add paused?, playing?, and stopped? methods.
-rw-r--r--libmpd.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/libmpd.rb b/libmpd.rb
index f71d156..48f999c 100644
--- a/libmpd.rb
+++ b/libmpd.rb
@@ -216,6 +216,27 @@ class MPD
return send_request 'single %s' % state.to_i
end
+ # Returns +true+ if playing.
+ # Otherwise, returns +false+.
+ def playing?
+ return true if status[:state] == 'play'
+ return false
+ end
+
+ # Returns +true+ if paused.
+ # Otherwise, returns +false+.
+ def paused?
+ return true if status[:state] == 'pause'
+ return false
+ end
+
+ # Returns +true+ if stopped.
+ # Otherwise, returns +false+.
+ def stopped?
+ return true if status[:state] == 'stop'
+ return false
+ end
+
private :generate_hash
private :get_response
private :split_and_hash