Class: OutlineVideoPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- OutlineVideoPresenter
- Defined in:
- app/presenters/outline_video_presenter.rb
Constant Summary collapse
- REQUIRED_ATTRIBUTES =
[:enabled, :completed, :id, :duration, :url, :name]
Instance Method Summary collapse
- #completed ⇒ Object
- #css_class ⇒ Object
- #duration ⇒ Object
-
#initialize(video) ⇒ OutlineVideoPresenter
constructor
A new instance of OutlineVideoPresenter.
- #slug ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(video) ⇒ OutlineVideoPresenter
Returns a new instance of OutlineVideoPresenter.
6 7 8 9 |
# File 'app/presenters/outline_video_presenter.rb', line 6 def initialize(video) super(video) check_attributes end |
Instance Method Details
#completed ⇒ Object
35 36 37 |
# File 'app/presenters/outline_video_presenter.rb', line 35 def completed yield if video.completed end |
#css_class ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/presenters/outline_video_presenter.rb', line 11 def css_class css_classes = [] css_classes << "disabled" if !video.enabled css_classes << "completed" if video.completed css_classes.join(" ") end |
#duration ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/presenters/outline_video_presenter.rb', line 23 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 |
#slug ⇒ Object
19 20 21 |
# File 'app/presenters/outline_video_presenter.rb', line 19 def slug "video_#{video.id}" end |
#url ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/presenters/outline_video_presenter.rb', line 39 def url if video.enabled video.url else "#" end end |