Sha256: 5df18c6009da5fcb48623d0b24092e7635ab9ef4014458b56b15766cde523679
Contents?: true
Size: 1.2 KB
Versions: 4
Compression:
Stored size: 1.2 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, :description 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 def render_description yield(video.description) unless video.description.nil? end private def video @delegate end end
Version data entries
4 entries across 4 versions & 1 rubygems