diff options
Diffstat (limited to 'mpdlib.rb')
-rw-r--r-- | mpdlib.rb | 29 |
1 files changed, 8 insertions, 21 deletions
@@ -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 |