Sha256: e175639a4b1f85067856c02f889037140e026214507c2554eada953fed8d3718

Contents?: true

Size: 499 Bytes

Versions: 29

Compression:

Stored size: 499 Bytes

Contents

class ContentVideoDecorator < ApplicationDecorator
  delegate_all

  def embed_url
    url.to_s.include?('vimeo') ? vimeo_embed_url : youtube_embed_url
  end

  def aspect_ratio_class
    aspect_ratio.to_s.split('x').join('by')
  end

  private

  def vimeo_embed_url
    video_id = /[0-9*]+/.match(url.to_s).to_s
    "https://player.vimeo.com/video/#{video_id}"
  end

  def youtube_embed_url
    video_id = url.to_s.split('v=').last
    "https://www.youtube.com/embed/#{video_id}?rel=0"
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
udongo-7.3.2 app/decorators/content_video_decorator.rb
udongo-7.3.1 app/decorators/content_video_decorator.rb
udongo-7.2.1 app/decorators/content_video_decorator.rb
udongo-7.2.0 app/decorators/content_video_decorator.rb
udongo-7.1.3 app/decorators/content_video_decorator.rb
udongo-7.1.2 app/decorators/content_video_decorator.rb
udongo-7.1.1 app/decorators/content_video_decorator.rb
udongo-7.1.0 app/decorators/content_video_decorator.rb
udongo-7.0.4 app/decorators/content_video_decorator.rb
udongo-7.0.3 app/decorators/content_video_decorator.rb
udongo-7.0.2 app/decorators/content_video_decorator.rb
udongo-7.0.1 app/decorators/content_video_decorator.rb
udongo-7.0.0 app/decorators/content_video_decorator.rb
udongo-6.6.3 app/decorators/content_video_decorator.rb
udongo-6.6.2 app/decorators/content_video_decorator.rb
udongo-6.6.1 app/decorators/content_video_decorator.rb
udongo-6.6.0 app/decorators/content_video_decorator.rb
udongo-6.5.2 app/decorators/content_video_decorator.rb
udongo-6.5.1 app/decorators/content_video_decorator.rb
udongo-6.5.0 app/decorators/content_video_decorator.rb