Class: Yt::Models::Resource

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

Direct Known Subclasses

Channel, Comment, CommentThread, Playlist, PlaylistItem, Video

Constant Summary collapse

PLAYLIST_PATTERNS =

Returns patterns matching URLs of YouTube playlists.

Returns:

  • (Array<Regexp>)

    patterns matching URLs of YouTube playlists.

[
   %r{^(?:https?://)?(?:www\.)?youtube\.com/playlist/?\?list=(?<id>[a-zA-Z0-9_-]+)},
]
VIDEO_PATTERNS =

Returns patterns matching URLs of YouTube videos.

Returns:

  • (Array<Regexp>)

    patterns matching URLs of YouTube videos.

[
  %r{^(?:https?://)?(?:www\.)?youtube\.com/watch\?v=(?<id>[a-zA-Z0-9_-]{11})},
  %r{^(?:https?://)?(?:www\.)?youtu\.be/(?<id>[a-zA-Z0-9_-]{11})},
  %r{^(?:https?://)?(?:www\.)?youtube\.com/embed/(?<id>[a-zA-Z0-9_-]{11})},
  %r{^(?:https?://)?(?:www\.)?youtube\.com/v/(?<id>[a-zA-Z0-9_-]{11})},
]
CHANNEL_PATTERNS =

Returns patterns matching URLs of YouTube channels.

Returns:

  • (Array<Regexp>)

    patterns matching URLs of YouTube channels.

[
  %r{^(?:https?://)?(?:www\.)?youtube\.com/channel/(?<id>UC[a-zA-Z0-9_-]{22})},
  %r{^(?:https?://)?(?:www\.)?youtube\.com/(?<format>c/|user/)?(?<name>[a-zA-Z0-9_-]+)}
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject (readonly)



15
16
17
18
19
20
21
# File 'lib/yt/models/resource.rb', line 15

def id
  if @id.nil? && @match && @match[:kind] == :channel
    @id ||= fetch_channel_id
  else
    @id
  end
end

#privacy_statusString (readonly)

Returns the privacy status of the resource. Possible values are: ‘private’, ‘public’, ‘unlisted’.

Returns:

  • (String)

    the privacy status of the resource. Possible values are: ‘private’, ‘public’, ‘unlisted’.



30
# File 'lib/yt/models/resource.rb', line 30

delegate :privacy_status, to: :status

Instance Method Details

#private?Boolean

Returns whether the resource is private.

Returns:

  • (Boolean)

    whether the resource is private.



38
39
40
# File 'lib/yt/models/resource.rb', line 38

def private?
  privacy_status == 'private'
end

#public?Boolean

Returns whether the resource is public.

Returns:

  • (Boolean)

    whether the resource is public.



33
34
35
# File 'lib/yt/models/resource.rb', line 33

def public?
  privacy_status == 'public'
end

#unlisted?Boolean

Returns whether the resource is unlisted.

Returns:

  • (Boolean)

    whether the resource is unlisted.



43
44
45
# File 'lib/yt/models/resource.rb', line 43

def unlisted?
  privacy_status == 'unlisted'
end