Class: Yt::Models::PlaylistItem

Inherits:
Base
  • Object
show all
Defined in:
lib/yt/models/playlist_item.rb

Overview

Provides methods to interact with YouTube playlist items.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PlaylistItem

Returns a new instance of PlaylistItem.



18
19
20
21
22
23
24
25
# File 'lib/yt/models/playlist_item.rb', line 18

def initialize(options = {})
  @id = options[:id]
  @auth = options[:auth]
  if options[:snippet]
    @position = options[:snippet]['position']
    @video = Video.new video_params_for options
  end
end

Instance Attribute Details

#idString (readonly)

Returns the ID that uniquely identify a YouTube playlist item.

Returns:

  • (String)

    the ID that uniquely identify a YouTube playlist item.



9
10
11
# File 'lib/yt/models/playlist_item.rb', line 9

def id
  @id
end

#positionString (readonly)

Returns the order in which the item appears in the playlist. The value uses a zero-based index, so the first item has a position of 0, the second item has a position of 1, and so forth.

Returns:

  • (String)

    the order in which the item appears in the playlist. The value uses a zero-based index, so the first item has a position of 0, the second item has a position of 1, and so forth.



14
15
16
# File 'lib/yt/models/playlist_item.rb', line 14

def position
  @position
end

#videoObject (readonly)

Returns the value of attribute video.



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

def video
  @video
end

Instance Method Details

#delete(options = {}) ⇒ Object



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

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

#exists?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/yt/models/playlist_item.rb', line 32

def exists?
  !@id.nil?
end