Class: ArticleJSON::Import::GoogleDoc::HTML::EmbeddedYoutubeVideoParser

Inherits:
EmbeddedParser
  • Object
show all
Defined in:
lib/article_json/import/google_doc/html/embedded_youtube_video_parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from EmbeddedParser

build, #element, #embed_id, #initialize, matches?, supported?, #tags

Methods included from Shared::Caption

#caption

Constructor Details

This class inherits a constructor from ArticleJSON::Import::GoogleDoc::HTML::EmbeddedParser

Class Method Details

.url_regexpRegexp

Regular expression to check if a given string is a Youtube URL Also used to extract the ID from the URL.

Returns:

  • (Regexp)


16
17
18
19
20
21
22
23
24
25
26
27
# 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

Instance Method Details

#embed_typeSymbol

The type of this embedded element

Returns:

  • (Symbol)


8
9
10
# File 'lib/article_json/import/google_doc/html/embedded_youtube_video_parser.rb', line 8

def embed_type
  :youtube_video
end