diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2009-07-21 15:50:04 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2009-07-21 15:50:04 -0700 |
commit | ff0ff2ac54d47123088c6819b62a2f72a7f61166 (patch) | |
tree | 615a5f695deffc1cbffdb5c8a45d5ff2a1f1d345 | |
parent | 36d8e7b37af77beb9718dbf292425085c29b83ca (diff) | |
download | ruby-libmpd-ff0ff2ac54d47123088c6819b62a2f72a7f61166.tar.gz ruby-libmpd-ff0ff2ac54d47123088c6819b62a2f72a7f61166.tar.xz |
Remove redundant code with generate_hash method.
-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 |