Class: ArticleJSON::Import::GoogleDoc::HTML::EmbeddedSlideshareParser
- Inherits:
-
EmbeddedParser
- Object
- EmbeddedParser
- ArticleJSON::Import::GoogleDoc::HTML::EmbeddedSlideshareParser
- Defined in:
- lib/article_json/import/google_doc/html/embedded_slideshare_parser.rb
Class Method Summary collapse
-
.url_regexp ⇒ Regexp
Regular expression to check if a given string is a Slideshare URL Also used to extract HANDLE and ID from the URL.
Instance Method Summary collapse
-
#embed_id ⇒ String
Extract the slide show ID (including the handle) from an URL.
-
#embed_type ⇒ Symbol
The type of this embedded element.
Methods inherited from EmbeddedParser
build, #element, #initialize, matches?, supported?, #tags
Methods included from Shared::Caption
Constructor Details
This class inherits a constructor from ArticleJSON::Import::GoogleDoc::HTML::EmbeddedParser
Class Method Details
.url_regexp ⇒ Regexp
Regular expression to check if a given string is a Slideshare URL Also used to extract HANDLE and ID from the URL.
23 24 25 26 27 28 29 30 |
# File 'lib/article_json/import/google_doc/html/embedded_slideshare_parser.rb', line 23 def url_regexp %r{ ^\S* # all protocols & sub domains slideshare\.net/ # domain (?<handle>[^/\s]+)/ # username / handle (?<id>[^/?&\s\u00A0]+) # the id / slug of the slide show }xi end |
Instance Method Details
#embed_id ⇒ String
Extract the slide show ID (including the handle) from an URL
14 15 16 17 |
# File 'lib/article_json/import/google_doc/html/embedded_slideshare_parser.rb', line 14 def match = @node.inner_text.strip.match(self.class.url_regexp) "#{match[:handle]}/#{match[:id]}" if match end |
#embed_type ⇒ Symbol
The type of this embedded element
8 9 10 |
# File 'lib/article_json/import/google_doc/html/embedded_slideshare_parser.rb', line 8 def :slideshare end |