Class: Bulbasaur::ExtractImagesFromYoutube
- Inherits:
-
Object
- Object
- Bulbasaur::ExtractImagesFromYoutube
- Defined in:
- lib/bulbasaur/extracts/extract_images_from_youtube.rb
Constant Summary collapse
- EXTRACT_URL_PATTERN =
/www\.youtube(?:-nocookie)?\.com\/(?:v|embed)\/[a-zA-Z0-9-]+/i- EXTRACT_VID_PATTERN =
/(?<=v|embed)\/(?<vid>[a-zA-Z0-9-]+)/i
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(html) ⇒ ExtractImagesFromYoutube
constructor
A new instance of ExtractImagesFromYoutube.
Constructor Details
#initialize(html) ⇒ ExtractImagesFromYoutube
8 9 10 |
# File 'lib/bulbasaur/extracts/extract_images_from_youtube.rb', line 8 def initialize(html) @html = html end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/bulbasaur/extracts/extract_images_from_youtube.rb', line 12 def call images = Array.new @html.scan(EXTRACT_URL_PATTERN).each do |video| vid = get_vid(video) images << { url: image_url(vid), video_url: video, source: 'youtube' } end images end |