Class: OutlineVideoPresenter

Inherits:
ExplicitDelegator show all
Includes:
ActionView::Helpers::UrlHelper
Defined in:
app/presenters/outline_video_presenter.rb

Instance Method Summary collapse

Methods inherited from ExplicitDelegator

enforce_definitions, #enforced_methods, #ensure_defined, #initialize

Constructor Details

This class inherits a constructor from ExplicitDelegator

Instance Method Details

#css_classObject



9
10
11
12
13
14
15
# File 'app/presenters/outline_video_presenter.rb', line 9

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

  css_classes.join(" ")
end

#durationObject



21
22
23
24
25
26
27
28
29
30
31
# File 'app/presenters/outline_video_presenter.rb', line 21

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

#linkable?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/presenters/outline_video_presenter.rb', line 55

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

#playback_classObject



41
42
43
44
45
46
47
48
49
# File 'app/presenters/outline_video_presenter.rb', line 41

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

#playback_iconObject



51
52
53
# File 'app/presenters/outline_video_presenter.rb', line 51

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

#render_description {|video.description| ... } ⇒ Object

Yields:

  • (video.description)


59
60
61
# File 'app/presenters/outline_video_presenter.rb', line 59

def render_description
  yield(video.description) unless video.description.nil?
end

#render_now_playingObject



63
64
65
# File 'app/presenters/outline_video_presenter.rb', line 63

def render_now_playing
  yield if video.now_playing?
end

#slugObject



17
18
19
# File 'app/presenters/outline_video_presenter.rb', line 17

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

#urlObject



33
34
35
36
37
38
39
# File 'app/presenters/outline_video_presenter.rb', line 33

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