Class: Yt::Models::Description
- Inherits:
-
String
- Object
- String
- Yt::Models::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
37 38 39 40 41 |
# File 'lib/yt/models/description.rb', line 37 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 links.any?{|link| link.kind == :channel} 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
65 66 67 |
# File 'lib/yt/models/description.rb', line 65 def has_link_to_playlist? links.any?{|link| link.kind == :playlist} 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
51 52 53 54 55 |
# File 'lib/yt/models/description.rb', line 51 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 links.any?{|link| link.kind == :subscription} 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
23 24 25 26 27 |
# File 'lib/yt/models/description.rb', line 23 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 links.any?{|link| link.kind == :video} end |