Sha256: e8db6b1a1cf81bc73e2334d41c0ee004947e6b2f2c4efedfa416fac888dc3b38

Contents?: true

Size: 402 Bytes

Versions: 48

Compression:

Stored size: 402 Bytes

Contents

module Coco
  module Embeds
    class Youtube < Coco::Component
      component_name :youtube_embed

      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
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
coveragebook_components-0.12.2 app/components/coco/shared/embeds/youtube/youtube.rb
coveragebook_components-0.12.1 app/components/coco/shared/embeds/youtube/youtube.rb
coveragebook_components-0.12.0 app/components/coco/shared/embeds/youtube/youtube.rb
coveragebook_components-0.11.0 app/components/coco/shared/embeds/youtube/youtube.rb
coveragebook_components-0.10.1.beta.2 app/components/coco/shared/embeds/youtube/youtube.rb
coveragebook_components-0.10.1.beta.1 app/components/coco/shared/embeds/youtube/youtube.rb
coveragebook_components-0.10.1.beta.0 app/components/coco/shared/embeds/youtube/youtube.rb
coveragebook_components-0.10.0 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.9.1 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.9.0 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.8.9 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.8.8 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.8.7 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.8.6 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.8.5 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.8.4 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.8.3 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.8.2 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.8.1 app/components/coco/base/embeds/youtube/youtube.rb
coveragebook_components-0.8.0 app/components/coco/base/embeds/youtube/youtube.rb