From cff0409822f20022d82280f2f50305c4b4ebce85 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Thu, 23 Jul 2009 19:29:31 -0700 Subject: Add paused?, playing?, and stopped? methods. --- libmpd.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'libmpd.rb') 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 -- cgit v1.2.3-70-g09d2