lib/turntabler/song.rb
def add(options = {})
      assert_valid_keys(options, :playlist, :index)
      options = {:playlist => playlist.id, :index => 0}.merge(options)

      # Create a copy of the song so that the playlist can get set properly
      song = dup
      song.attributes = {:playlist => options[:playlist]}
      playlist, index = song.playlist, options[:index]

      api('playlist.add', :playlist_name => playlist.id, :song_dict => {:fileid => id}, :index => index)
      playlist.songs.insert(index, song) if playlist.loaded?
      true
    end
def add(options = {})
      assert_valid_keys(options, :playlist, :index)
      options = {:playlist => playlist.id, :index => 0}.merge(options)

      # Create a copy of the song so that the playlist can get set properly
      song = dup
      song.attributes = {:playlist => options[:playlist]}
      playlist, index = song.playlist, options[:index]

      api('playlist.add', :playlist_name => playlist.id, :song_dict => {:fileid => id}, :index => index)
      playlist.songs.insert(index, song) if playlist.loaded?
      true
    end
def add ( options = { } ) assert_valid_keys ( options , :playlist , :index ) options = { :playlist => playlist . id , :index => 0 } . merge ( options ) # Create a copy of the song so that the playlist can get set properly song = dup song . attributes = { :playlist => options [ :playlist ] } playlist , index = song . playlist , options [ :index ] api ( 'playlist.add' , :playlist_name => playlist . id , :song_dict => { :fileid => id } , :index => index ) playlist . songs . insert ( index , song ) if playlist . loaded? true end
Adds the song to one of the user's playlists.

 @param [Hash] options The options for where to add the song
 @option options [String] :playlist ("default") The playlist to add the song in
 @option options [Fixnum] :index (0) The location in the playlist to insert the song
 @return [true]
 @raise [ArgumentError] if an invalid option is specified
 @raise [Turntabler::Error] if the command fails
 @example
   song.add(:index => 1)   # => true
Adds the song to one of the user s playlists .