Sha256: 347c9e17386f8bca74ba7b839d43b30a7f90ffa3f3bc4b94bfb15cdaa66095d0

Contents?: true

Size: 777 Bytes

Versions: 16

Compression:

Stored size: 777 Bytes

Contents

# frozen_string_literal: true

module Lcms
  module Engine
    class MediaPresenter < Lcms::Engine::ResourcePresenter
      def media_title
        [subject, resource_type].compact.join(' ').titleize
      end

      def embed_podcast
        MediaEmbed.soundcloud(url, try(:subject).try(:to_sym)) if url.match?(/soundcloud/)
      end

      def embed_video_url
        url.match?(/vimeo/) ? embed_video_vimeo_url : embed_video_youtube_url
      end

      private

      def embed_video_youtube_url
        video_id = MediaEmbed.video_id(url)
        "//www.youtube.com/embed/#{video_id}" if video_id
      end

      def embed_video_vimeo_url
        video_id = MediaEmbed.video_id(url)
        "//player.vimeo.com/video/#{video_id}" if video_id
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.5.4 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.5.3 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.5.2 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.5.1 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.5.0 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.4.2 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.4.1 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.4.0 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.3.1 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.1.4 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.3.0 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.1.3 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.2.0 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.1.2 app/presenters/lcms/engine/media_presenter.rb
lcms-engine-0.1.0 app/presenters/lcms/engine/media_presenter.rb