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 |
# File 'lib/yt/models/resource.rb', line 15 def id @id ||= @match['id'] || fetch_channel_id end |
#privacy_status ⇒ String (readonly)
Returns the privacy status of the resource. Possible values are: ‘private’, ‘public’, ‘unlisted’.
26 |
# File 'lib/yt/models/resource.rb', line 26 delegate :privacy_status, to: :status |
Instance Method Details
#private? ⇒ Boolean
Returns whether the resource is private.
34 35 36 |
# File 'lib/yt/models/resource.rb', line 34 def private? privacy_status == 'private' end |
#public? ⇒ Boolean
Returns whether the resource is public.
29 30 31 |
# File 'lib/yt/models/resource.rb', line 29 def public? privacy_status == 'public' end |
#unlisted? ⇒ Boolean
Returns whether the resource is unlisted.
39 40 41 |
# File 'lib/yt/models/resource.rb', line 39 def unlisted? privacy_status == 'unlisted' end |