Sha256: 85b864b9e9867e4a79df966e3a59a21d92b41da5467378779eaad45cee1b93dd
Contents?: true
Size: 1.1 KB
Versions: 9
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 __getobj__ end end
Version data entries
9 entries across 9 versions & 1 rubygems