Class: Yt::Description

Inherits:
String
  • Object
show all
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

Instance Method Details

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

Returns:

  • (Boolean)

    Whether the description includes a link to a channel



34
35
36
37
38
# File 'lib/yt/models/description.rb', line 34

def has_link_to_channel?(options = {}) # 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

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

Returns:

  • (Boolean)

    Whether the description includes a link to a playlist



62
63
64
# File 'lib/yt/models/description.rb', line 62

def has_link_to_playlist?
  regex? :playlist_long_url, :playlist_embed_url
end

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

Returns:

  • (Boolean)

    Whether the description includes a link to subscribe



48
49
50
51
52
# File 'lib/yt/models/description.rb', line 48

def has_link_to_subscribe?(options = {}) # 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

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

Returns:

  • (Boolean)

    Whether the description includes a link to a video



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