Sha256: 8e603bcdd1f11ecee5d41b44bcd0e379a49907f660f3e013af2583fc4a5ad373

Contents?: true

Size: 1.1 KB

Versions: 19

Compression:

Stored size: 1.1 KB

Contents

require 'action_view/helpers/url_helper'
require 'explicit_delegator'

class OutlineVideoPresenter < ExplicitDelegator
  include ActionView::Helpers::UrlHelper

  enforce_definitions :enabled, :completed, :id, :duration, :url, :name

  def css_class
    css_classes = []
    css_classes << "disabled" if !video.enabled
    css_classes << "completed" if video.completed

    css_classes.join(" ")
  end

  def slug
    "video_#{video.id}"
  end

  def duration
    minutes = (video.duration.to_f / 1000.0 / 60.0).floor
    remainder = (video.duration - (minutes * 60 * 1000))
    seconds = (remainder.to_f / 1000.0).floor

    if seconds <= 9
      seconds = "0#{seconds}"
    end

    "#{minutes}:#{seconds}"
  end

  def url
    if video.enabled
      video.url
    else
      "#"
    end
  end

  def playback_class
    if video.completed
      "icon-ok"
    elsif video.enabled
      "icon-play"
    else
      "icon-lock"
    end
  end

  def playback_icon
    content_tag(:i, nil, class: playback_class)
  end

  def linkable?
    video.completed || video.enabled
  end

  private

  def video
    @delegate
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
woople-theme-0.8.4 app/presenters/outline_video_presenter.rb
woople-theme-0.8.3 app/presenters/outline_video_presenter.rb
woople-theme-0.8.2 app/presenters/outline_video_presenter.rb
woople-theme-0.8.1 app/presenters/outline_video_presenter.rb
woople-theme-0.8.0 app/presenters/outline_video_presenter.rb
woople-theme-0.6.27 app/presenters/outline_video_presenter.rb
woople-theme-0.6.26 app/presenters/outline_video_presenter.rb
woople-theme-0.6.25 app/presenters/outline_video_presenter.rb
woople-theme-0.6.24 app/presenters/outline_video_presenter.rb
woople-theme-0.6.23 app/presenters/outline_video_presenter.rb
woople-theme-0.6.22 app/presenters/outline_video_presenter.rb
woople-theme-0.6.21 app/presenters/outline_video_presenter.rb
woople-theme-0.6.20 app/presenters/outline_video_presenter.rb
woople-theme-0.6.19 app/presenters/outline_video_presenter.rb
woople-theme-0.6.18 app/presenters/outline_video_presenter.rb
woople-theme-0.6.17 app/presenters/outline_video_presenter.rb
woople-theme-0.6.14 app/presenters/outline_video_presenter.rb
woople-theme-0.6.13 app/presenters/outline_video_presenter.rb
woople-theme-0.6.12 app/presenters/outline_video_presenter.rb