class ArticleJSON::Import::GoogleDoc::HTML::EmbeddedYoutubeVideoParser

Public Class Methods

url_regexp() click to toggle source

Regular expression to check if a given string is a Youtube URL Also used to extract the ID from the URL. @return [Regexp]

# File lib/article_json/import/google_doc/html/embedded_youtube_video_parser.rb, line 16
def url_regexp
  %r{
    ^\S*                   # all protocols & sub domains
    (                      # different domains / paths
      youtube\.com/(
        [^/]+/.+/|(v|e(mbed)?)/|.*[?&]v=
      )|
      youtu\.be/
    )
    (?<id>[a-zA-Z0-9_-]+)  # alpha-numerical id, including _-
  }xi
end

Public Instance Methods

embed_type() click to toggle source

The type of this embedded element @return [Symbol]

# File lib/article_json/import/google_doc/html/embedded_youtube_video_parser.rb, line 8
def embed_type
  :youtube_video
end