Method: MPD::Plugins::Queue#move

Defined in:
lib/ruby-mpd/plugins/queue.rb

#move(from, to) ⇒ Boolean

Move the song at from to to in the queue.

  • Since 0.14, to can be a negative number, which is the offset of the song from the currently playing (or to-be-played) song. So -1 would mean the song would be moved to be the next song in the queue. Moving a song to -queue.length will move it to the song before the current song on the queue; so this will work for repeating playlists, too.

  • Since 0.15, from can be a range of songs to move.

Parameters:

  • from (Hash)

    :id to specify the song ID to move instead of position.

Returns:

  • (Boolean)

    returns true if successful.



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/ruby-mpd/plugins/queue.rb', line 66

def move(from, to)
  if from.is_a?(Hash)
    if from[:id]
      send_command :moveid, from[:id], to
    else
      raise ArgumentError, 'Only :id key is allowed!'
    end
  else
    send_command :move, from, to
  end
end