Sha256: f6bdd9b60e03086265a5cb6e6344d8aee43ee32241b64df400af3307b71a8740

Contents?: true

Size: 729 Bytes

Versions: 6

Compression:

Stored size: 729 Bytes

Contents

require 'delegate'

class OutlineVideoPresenter < SimpleDelegator
  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 completed
    yield if video.completed
  end

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

  private

  def video
    __getobj__
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
woople-theme-0.1.0 app/presenters/outline_video_presenter.rb
woople-theme-0.0.6 app/presenters/outline_video_presenter.rb
woople-theme-0.0.5 app/presenters/outline_video_presenter.rb
woople-theme-0.0.4 app/presenters/outline_video_presenter.rb
woople-theme-0.0.3 app/presenters/outline_video_presenter.rb
woople-theme-0.0.2 app/presenters/outline_video_presenter.rb