summaryrefslogtreecommitdiff
path: root/mpdlib.rb
diff options
context:
space:
mode:
Diffstat (limited to 'mpdlib.rb')
-rw-r--r--mpdlib.rb29
1 files changed, 8 insertions, 21 deletions
diff --git a/mpdlib.rb b/mpdlib.rb
index 4519787..e1d3332 100644
--- a/mpdlib.rb
+++ b/mpdlib.rb
@@ -37,11 +37,10 @@ class MPD
end
end
- def currentsong
- response = send_request('currentsong')
+ def generate_hash str
hash = Hash.new
- response.split("\n").each do |line|
+ str.split("\n").each do |line|
field, value = line.split(': ')
hash[field] = value
end
@@ -49,27 +48,15 @@ class MPD
return hash
end
- def status
- response = send_request('status')
- hash = Hash.new
-
- response.split("\n").each do |line|
- field, value = line.split(': ')
- hash[field] = value
- end
+ def currentsong
+ return generate_hash send_request 'currentsong'
+ end
- return hash
+ def status
+ return generate_hash send_request 'status'
end
def stats
- response = send_request('stats')
- hash = Hash.new
-
- response.split("\n").each do |line|
- field, value = line.split(': ')
- hash[field] = value
- end
-
- return hash
+ return generate_hash send_request 'stats'
end
end