Class: Yt::Models::PlaylistItem

Inherits:
Resource show all
Defined in:
lib/yt/models/playlist_item.rb

Overview

Provides methods to interact with YouTube playlist items.

Instance Attribute Summary

Attributes inherited from Resource

#auth

Instance Method Summary collapse

Methods inherited from Resource

#initialize, #kind, #update, #username

Methods included from Associations::HasReports

#has_report

Methods included from Associations::HasViewerPercentages

#has_viewer_percentages

Methods included from Associations::HasOne

#has_one

Methods included from Associations::HasMany

#has_many

Methods included from Associations::HasAuthentication

#has_authentication

Constructor Details

This class inherits a constructor from Yt::Models::Resource

Instance Method Details

#delete(options = {}) ⇒ Object



11
12
13
14
# File 'lib/yt/models/playlist_item.rb', line 11

def delete(options = {})
  do_delete {@id = nil}
  !exists?
end

#exists?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/yt/models/playlist_item.rb', line 16

def exists?
  !@id.nil?
end

#positionInteger

Returns the position of the item in the playlist. Since YouTube API does not return the position on PlaylistItem#create, the memoized @snippet is erased if the video was instantiated like that, so that the full snippet (with position) is loaded, rather than the partial one.

Returns:

  • (Integer)

    the order in which the item appears in a playlist.

See Also:



27
28
29
30
31
32
# File 'lib/yt/models/playlist_item.rb', line 27

def position
  unless snippet.position || snippet.complete? || @auth.nil?
    @snippet = nil
  end
  snippet.position
end