diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-07-06 16:09:47 -0700 | 
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-07-06 16:09:47 -0700 | 
| commit | 602cbf21d35ba898841cac0f3c458bd90b6b6841 (patch) | |
| tree | 0d8b282562d866ff70d833666a383a50d6714f4e /libmpd | |
| parent | 4ebf4d0b5e8de5a79efa3811eb35ac8b85f26b07 (diff) | |
| download | ruby-libmpd-602cbf21d35ba898841cac0f3c458bd90b6b6841.tar.gz ruby-libmpd-602cbf21d35ba898841cac0f3c458bd90b6b6841.tar.xz | |
Style changes and simpler code.
Diffstat (limited to 'libmpd')
| -rw-r--r-- | libmpd/database.rb | 8 | ||||
| -rw-r--r-- | libmpd/playbackcontrol.rb | 31 | ||||
| -rw-r--r-- | libmpd/playbackoptions.rb | 38 | ||||
| -rw-r--r-- | libmpd/playlist.rb | 24 | ||||
| -rw-r--r-- | libmpd/status.rb | 10 | 
5 files changed, 52 insertions, 59 deletions
| diff --git a/libmpd/database.rb b/libmpd/database.rb index e5f86b3..4249f5e 100644 --- a/libmpd/database.rb +++ b/libmpd/database.rb @@ -1,7 +1,7 @@  #!/usr/bin/env ruby  #  #-- -# Copyright 2009 David Vazgenovich Shakaryan <dvshakaryan@gmail.com> +# Copyright 2009-2014 David Vazgenovich Shakaryan <dvshakaryan@gmail.com>  # Distributed under the terms of the GNU General Public License v3.  # See http://www.gnu.org/licenses/gpl.txt for the full license text.  #++ @@ -13,7 +13,7 @@  module MPDDatabase    # Returns all directories.    # If an argument is specified, list all subdirectories of that directory. -  def directories(uri=nil) +  def directories(uri = nil)      command = 'lsinfo'      command << ' "%s"' % uri if uri @@ -41,7 +41,7 @@ module MPDDatabase    # Returns all files.    # If an argument is specified, list all files in that directory. -  def files(uri=nil) +  def files(uri = nil)      command = 'lsinfo'      command << ' "%s"' % uri if uri @@ -67,7 +67,7 @@ module MPDDatabase    # Updates the database.    # If an argument is given, update that particular file or directory. -  def update(uri=nil) +  def update(uri = nil)      command = 'update'      command << ' "%s"' % uri if uri diff --git a/libmpd/playbackcontrol.rb b/libmpd/playbackcontrol.rb index 1e7a9c4..5707703 100644 --- a/libmpd/playbackcontrol.rb +++ b/libmpd/playbackcontrol.rb @@ -1,7 +1,7 @@  #!/usr/bin/env ruby  #  #-- -# Copyright 2009 David Vazgenovich Shakaryan <dvshakaryan@gmail.com> +# Copyright 2009-2014 David Vazgenovich Shakaryan <dvshakaryan@gmail.com>  # Distributed under the terms of the GNU General Public License v3.  # See http://www.gnu.org/licenses/gpl.txt for the full license text.  #++ @@ -13,69 +13,66 @@  module MPDPlaybackControl    # Plays the next song in the playlist.    def next -    return send_request('next') +    send_request('next')    end    # Sets pause state.    #    # Accepts an argument of +true+ to enable or +false+ to disable.    # If no argument is given, defaults to +true+. -  def pause(state=true) -    return send_request('pause %s' % state.to_i) +  def pause(state = true) +    send_request('pause %s' % state.to_i)    end    # Returns +true+ if paused.    # Otherwise, returns +false+.    def paused? -    return true if status[:state] == 'pause' -    return false +    status[:state] == 'pause'    end    # Begins playing the playlist. If an argument is given, begins at the    # specified song position. -  def play(songpos=nil) +  def play(songpos = nil)      command = 'play'      command << ' %s' % songpos if songpos -    return send_request(command) +    send_request(command)    end    # Begins playing the playlist. If an argument is given, begins at the    # specified song id. -  def playid(songid=nil) +  def playid(songid = nil)      command = 'playid'      command << ' %s' % songid if songid -    return send_request(command) +    send_request(command)    end    # Returns +true+ if playing.    # Otherwise, returns +false+.    def playing? -    return true if status[:state] == 'play' -    return false +    status[:state] == 'play'    end    # Plays the previous song in the playlist.    def previous -    return send_request('previous') +    send_request('previous')    end    # Seeks to the given position of the current song.    # Accepts an argument of seconds.    def seek(time) -    return send_request('seek %s %s' % [status[:song], time]) +    send_request('seek %s %s' % [status[:song], time])    end    # Stops playing.    def stop -    return send_request('stop') +    send_request('stop')    end    # Returns +true+ if stopped.    # Otherwise, returns +false+.    def stopped? -    return true if status[:state] == 'stop' -    return false +    status[:state] == 'stop'    end  end diff --git a/libmpd/playbackoptions.rb b/libmpd/playbackoptions.rb index f9d39ec..84afd47 100644 --- a/libmpd/playbackoptions.rb +++ b/libmpd/playbackoptions.rb @@ -1,7 +1,7 @@  #!/usr/bin/env ruby  #  #-- -# Copyright 2009 David Vazgenovich Shakaryan <dvshakaryan@gmail.com> +# Copyright 2009-2014 David Vazgenovich Shakaryan <dvshakaryan@gmail.com>  # Distributed under the terms of the GNU General Public License v3.  # See http://www.gnu.org/licenses/gpl.txt for the full license text.  #++ @@ -16,65 +16,62 @@ module MPDPlaybackOptions    #    # Accepts an argument of +true+ to enable or +false+ to disable.    # If no argument is given, defaults to +true+. -  def consume(state=true) -    return send_request('consume %s' % state.to_i) +  def consume(state = true) +    send_request('consume %s' % state.to_i)    end    # Returns +true+ if consume is activated.    # Otherwise, returns +false+.    def consume? -    return true if status[:consume] == '1' -    return false +    status[:consume] == '1'    end    # Sets crossfading between songs.    def crossfade(seconds) -    return send_request('crossfade %s' % seconds) +    send_request('crossfade %s' % seconds)    end    # Returns the current crossfade setting as an integer.    def crossfade? -    return status[:xfade].to_i +    status[:xfade].to_i    end    # Sets random state.    #    # Accepts an argument of +true+ to enable or +false+ to disable.    # If no argument is given, defaults to +true+. -  def random(state=true) -    return send_request('random %s' % state.to_i) +  def random(state = true) +    send_request('random %s' % state.to_i)    end    # Returns +true+ if random is activated.    # Otherwise, returns +false+.    def random? -    return true if status[:random] == '1' -    return false +    status[:random] == '1'    end    # Sets repeat state.    #    # Accepts an argument of +true+ to enable or +false+ to disable.    # If no argument is given, defaults to +true+. -  def repeat(state=true) -    return send_request('repeat %s' % state.to_i) +  def repeat(state = true) +    send_request('repeat %s' % state.to_i)    end    # Returns +true+ if repeat is activated.    # Otherwise, returns +false+.    def repeat? -    return true if status[:repeat] == '1' -    return false +    status[:repeat] == '1'    end    # Sets volume from a range of 0 to 100.    def volume(volume) -    return send_request('setvol %s' % volume) +    send_request('setvol %s' % volume)    end    # Returns the current volume as an integer.    def volume? -    return status[:volume].to_i +    status[:volume].to_i    end    # Sets single state. @@ -83,14 +80,13 @@ module MPDPlaybackOptions    #    # Accepts an argument of +true+ to enable or +false+ to disable.    # If no argument is given, defaults to +true+. -  def single(state=true) -    return send_request('single %s' % state.to_i) +  def single(state = true) +    send_request('single %s' % state.to_i)    end    # Returns +true+ if single is activated.    # Otherwise, returns +false+.    def single? -    return true if status[:single] == '1' -    return false +    status[:single] == '1'    end  end diff --git a/libmpd/playlist.rb b/libmpd/playlist.rb index cc5db9f..d4be0b8 100644 --- a/libmpd/playlist.rb +++ b/libmpd/playlist.rb @@ -1,7 +1,7 @@  #!/usr/bin/env ruby  #  #-- -# Copyright 2009 David Vazgenovich Shakaryan <dvshakaryan@gmail.com> +# Copyright 2009-2014 David Vazgenovich Shakaryan <dvshakaryan@gmail.com>  # Distributed under the terms of the GNU General Public License v3.  # See http://www.gnu.org/licenses/gpl.txt for the full license text.  #++ @@ -14,46 +14,46 @@ module MPDPlaylist    # Adds the specified file to the playlist.    # Directories add recursively.    def add(uri) -    return send_request('add "%s"' % uri) +    send_request('add "%s"' % uri)    end    # Adds the specified file to the playlist and returns the song id.    # An optional playlist position can be specified. -  def addid(uri, position=nil) +  def addid(uri, position = nil)      command = 'addid "%s"' % uri      command << ' %s' % position if position -    return send_request(command).scan(/\d+/).first.to_i +    send_request(command).scan(/\d+/).first.to_i    end    # Clears the playlist.    def clear -    return send_request('clear') +    send_request('clear')    end    # Deletes a song from the playlist.    def delete(songpos) -    return send_request('delete %s' % songpos) +    send_request('delete %s' % songpos)    end    # Deletes a song from the playlist.    def deleteid(songid) -    return send_request('deleteid %s' % songid) +    send_request('deleteid %s' % songid)    end    # Returns an Array composed of Hashes containing information about the songs    # in the playlist.    def playlist -    return split_and_hash(send_request('playlistinfo')) +    split_and_hash(send_request('playlistinfo'))    end    # Swaps the positions of the given songs, specified by playlist positions. -  def swap first, second -    return send_request('swap %s %s' % [first, second]) +  def swap(first, second) +    send_request('swap %s %s' % [first, second])    end    # Swaps the positions of the given songs, specified by song ids. -  def swapid first, second -    return send_request('swapid %s %s' % [first, second]) +  def swapid(first, second) +    send_request('swapid %s %s' % [first, second])    end  end diff --git a/libmpd/status.rb b/libmpd/status.rb index 52c937c..d11c6ca 100644 --- a/libmpd/status.rb +++ b/libmpd/status.rb @@ -1,7 +1,7 @@  #!/usr/bin/env ruby  #  #-- -# Copyright 2009 David Vazgenovich Shakaryan <dvshakaryan@gmail.com> +# Copyright 2009-2014 David Vazgenovich Shakaryan <dvshakaryan@gmail.com>  # Distributed under the terms of the GNU General Public License v3.  # See http://www.gnu.org/licenses/gpl.txt for the full license text.  #++ @@ -13,21 +13,21 @@  module MPDStatus    # Clears the error message in the status, if one exists.    def clearerror -    return send_request('clearerror') +    send_request('clearerror')    end    # Returns information about the current song.    def current -    return generate_hash(send_request('currentsong')) +    generate_hash(send_request('currentsong'))    end    # Returns daemon and database statistics.    def stats -    return generate_hash(send_request('stats')) +    generate_hash(send_request('stats'))    end    # Returns the status.    def status -    return generate_hash(send_request('status')) +    generate_hash(send_request('status'))    end  end | 
