Class: Yt::Models::Resource
- Inherits:
-
Base
- Object
- Base
- Yt::Models::Resource
- 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.
[ %r{^(?:https?://)?(?:www\.)?youtube\.com/playlist/?\?list=(?<id>[a-zA-Z0-9_-]+)}, ]
- VIDEO_PATTERNS =
Returns 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.
[ %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
- #id ⇒ Object readonly
-
#privacy_status ⇒ String
readonly
The privacy status of the resource.
Instance Method Summary collapse
-
#private? ⇒ Boolean
Whether the resource is private.
-
#public? ⇒ Boolean
Whether the resource is public.
-
#unlisted? ⇒ Boolean
Whether the resource is unlisted.
Instance Attribute Details
#id ⇒ Object (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_status ⇒ String (readonly)
Returns 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.
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.
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.
43 44 45 |
# File 'lib/yt/models/resource.rb', line 43 def unlisted? privacy_status == 'unlisted' end |