Class: Yt::Description
- Inherits:
-
String
- Object
- String
- Yt::Description
- Defined in:
- lib/yt/models/description.rb
Overview
Provides read-only access to the description of a YouTube resource. Resources with descriptions are: videos and channels.
description = Yt::Description.new ‘Fullscreen provides a suite of end-to-end YouTube tools and services to many of the world’s leading brands and media companies.’ description.to_s.slice(0,19) # => ‘Fullscreen provides’ description.length # => 127
Instance Method Summary collapse
-
#has_link_to_channel?(options = {}) ⇒ Boolean
Returns whether the description includes a YouTube channel URL.
-
#has_link_to_playlist? ⇒ Boolean
Returns whether the description includes a YouTube playlist URL.
-
#has_link_to_subscribe?(options = {}) ⇒ Boolean
Returns whether the description includes a YouTube subscription URL.
-
#has_link_to_video? ⇒ Boolean
Returns whether the description includes a YouTube video URL.
Instance Method Details
#has_link_to_channel?(options = {}) ⇒ Boolean
Returns whether the description includes a YouTube channel URL
description = Yt::Description.new Link to channel: youtube.com/fullscreen description.has_link_to_channel? #=> true
34 35 36 37 38 |
# File 'lib/yt/models/description.rb', line 34 def has_link_to_channel?( = {}) # TODO: which channel # TODO: might take as an option WHICH channel to link to # in order to check if it's my own channel regex? :channel_long_url, :channel_short_url, :channel_user_url end |
#has_link_to_playlist? ⇒ Boolean
Returns whether the description includes a YouTube playlist URL
description = Yt::Description.new Link to playlist: youtube.com/playlist?list=LLxO1tY8h1AhOz0T4ENwmpow description.has_link_to_playlist? #=> true
62 63 64 |
# File 'lib/yt/models/description.rb', line 62 def has_link_to_playlist? regex? :playlist_long_url, :playlist_embed_url end |
#has_link_to_subscribe?(options = {}) ⇒ Boolean
Returns whether the description includes a YouTube subscription URL
description = Yt::Description.new Link to subscribe: youtube.com/subscription_center?add_user=fullscreen description.has_link_to_subscribe? #=> true
48 49 50 51 52 |
# File 'lib/yt/models/description.rb', line 48 def has_link_to_subscribe?( = {}) # TODO: which channel # TODO: might take as an option WHICH channel to subscribe to # in order to check if it's my own channel regex? :subscribe_center_url, :subscribe_widget_url, :subscribe_confirm_url end |
#has_link_to_video? ⇒ Boolean
Returns whether the description includes a YouTube video URL
description = Yt::Description.new ‘Link to video: youtube.com/watch?v=MESycYJytkU’ description.has_link_to_video? #=> true
20 21 22 23 24 |
# File 'lib/yt/models/description.rb', line 20 def has_link_to_video? # TODO: might take as an option WHICH video to link to # in order to check if it's my own video regex? :video_long_url, :video_short_url end |