Skip to content

Instantly share code, notes, and snippets.

View md-farhan-memon's full-sized avatar
🎯
Focusing

Md. Farhan Memon md-farhan-memon

🎯
Focusing
View GitHub Profile
@md-farhan-memon
md-farhan-memon / video_embed_url_generator.rb
Last active September 3, 2020 17:17 — forked from niquepa/gist:4c59b7d52a15dde2367a
Ruby/Rails generate YouTube or Vimeo embed video ifram from url
class VideoEmbedUrlGenerator
REGEX_ID = %r{(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/|vimeo\.com\/)([a-zA-Z0-9_-]{8,11})}.freeze
REGEX_PROVIDER = /(youtube|youtu\.be|vimeo)/.freeze
def initialize(url)
@url = url
end
def construct_iframe
'<iframe '\