Sha256: 23892d6d597c93d9b7e98120c9c993bf1c9f9cc7bf60b3e90cfbc5bfc12b3702

Contents?: true

Size: 324 Bytes

Versions: 25

Compression:

Stored size: 324 Bytes

Contents

module Coco
  class YoutubeEmbed < Coco::Component
    def initialize(url:, **kwargs)
      @url = url
    end

    def video_id
      youtube_url = /youtube.com\/(watch\?v=|v\/)([^&]+)/.match(@url)
      youtube_url[2] if youtube_url
    end

    def src
      "https://www.youtube.com/embed/#{video_id}"
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
coveragebook_components-0.19.8 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.19.7 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.19.6 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.19.5 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.19.4 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.19.3 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.19.2 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.19.1 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.19.0 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.18.8 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.18.7 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.18.0 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.17.7 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.17.6 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.17.5 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.17.4 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.17.3 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.17.2 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.17.1 app/components/coco/embeds/youtube_embed/youtube_embed.rb
coveragebook_components-0.17.0 app/components/coco/embeds/youtube_embed/youtube_embed.rb