class EmbedRb::YouTube

Public Class Methods

new(input, output, options, embeds) click to toggle source
# File lib/embedrb/video/embed_youtube.rb, line 8
def initialize(input, output, options, embeds)
  @input = input
  @output = output
  @embeds = embeds
  @options = options
  @regex = /(https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[?=&+%\w-]*)/mi
  @service = :youtube
end

Private Instance Methods

render(url) click to toggle source
# File lib/embedrb/video/embed_youtube.rb, line 23
    def render(url)
      dims = EmbedRb.get_dimensions(@options)
      return <<EOF
      <div class="ejs-video-player ejs-embed" style="width: #{dims[:width]}px; height: #{dims[:height]}px;">
        <iframe src="#{url}" frameBorder="0" width="#{dims[:width]}px" height="#{dims[:height]}px" ></iframe>
      </div>
EOF
    end
url_to_text(matched) click to toggle source
# File lib/embedrb/video/embed_youtube.rb, line 18
def url_to_text(matched)
  url = "https://www.youtube.com/embed/#{matched[1]}"
  return render url
end