Module: Kinney::Concerns::Models::Clip
- Extended by:
- ActiveSupport::Concern
- Included in:
- Kinney::Clip
- Defined in:
- lib/concerns/models/clip.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#chapters ⇒ Object
vtt file.
- #duration_iso8601 ⇒ Object
- #duration_pretty ⇒ Object
- #full_people_names ⇒ Object
- #mp4 ⇒ Object
- #pdf_transcript ⇒ Object
- #people_names ⇒ Object
- #people_with_title ⇒ Object
- #png ⇒ Object
- #related_topic_clips ⇒ Object
- #should_generate_new_friendly_id? ⇒ Boolean
- #text_transcript ⇒ Object
-
#title_and_filename ⇒ Object
hash.to_json end end elasticsearch end.
- #title_and_last_names ⇒ Object
- #title_with_full_people_names ⇒ Object
- #topic_names ⇒ Object
- #video_switcher_params ⇒ Object
-
#vtt ⇒ Object
closed_captioning vtt file.
- #webm ⇒ Object
Instance Method Details
#chapters ⇒ Object
vtt file
155 156 |
# File 'lib/concerns/models/clip.rb', line 155 def chapters #vtt file end |
#duration_iso8601 ⇒ Object
174 175 176 177 178 179 180 181 182 183 |
# File 'lib/concerns/models/clip.rb', line 174 def duration_iso8601 hours = duration / 1.hour minutes = (duration - hours.hours) / 1.minute seconds = duration - hours.hours - minutes.minutes output = 'T' output << "#{hours}H" if hours > 0 output << "#{minutes}M" if minutes > 0 output << "#{seconds}S" if seconds > 0 output end |
#duration_pretty ⇒ Object
185 186 187 188 189 190 191 |
# File 'lib/concerns/models/clip.rb', line 185 def duration_pretty if !duration.blank? total_minutes = duration / 1.minutes seconds_in_last_minute = duration - total_minutes.minutes.seconds %Q|#{total_minutes}:#{"%02d" % seconds_in_last_minute}| end end |
#full_people_names ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/concerns/models/clip.rb', line 126 def full_people_names names = people.map{|person| person.full_name} if names.length > 2 name_last = names.pop final_names = names.join(', ') final_names << ', and ' << name_last elsif names.length == 2 names.join(' and ') else names.first end end |
#mp4 ⇒ Object
143 144 145 |
# File 'lib/concerns/models/clip.rb', line 143 def mp4 siskel_path({:extension => 'mp4'}) end |
#pdf_transcript ⇒ Object
158 159 160 |
# File 'lib/concerns/models/clip.rb', line 158 def pdf_transcript siskel_path({suffix: '-transcript', extension: 'pdf'}) end |
#people_names ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/concerns/models/clip.rb', line 113 def people_names names = people.map{|person| person.last_name} if names.length > 2 name_last = names.pop final_names = names.join(', ') final_names << ', and ' << name_last elsif names.length == 2 names.join(' and ') else names.first end end |
#people_with_title ⇒ Object
109 110 111 |
# File 'lib/concerns/models/clip.rb', line 109 def people_with_title "#{people_names}: #{title}" end |
#png ⇒ Object
139 140 141 |
# File 'lib/concerns/models/clip.rb', line 139 def png siskel_path({:extension => 'png'}) end |
#related_topic_clips ⇒ Object
193 194 195 196 |
# File 'lib/concerns/models/clip.rb', line 193 def # FIXME: this could probably done in one nice query topics.map{|topic| topic.clips}.flatten.uniq - [self] end |
#should_generate_new_friendly_id? ⇒ Boolean
198 199 200 201 |
# File 'lib/concerns/models/clip.rb', line 198 def should_generate_new_friendly_id? binding.pry slug.blank? || title_changed? end |
#text_transcript ⇒ Object
162 163 164 |
# File 'lib/concerns/models/clip.rb', line 162 def text_transcript siskel_path({suffix: '-transcript', extension: 'txt'}) end |
#title_and_filename ⇒ Object
hash.to_json end end elasticsearch end
93 94 95 |
# File 'lib/concerns/models/clip.rb', line 93 def title_and_filename "#{title} #{filename}" end |
#title_and_last_names ⇒ Object
97 98 99 |
# File 'lib/concerns/models/clip.rb', line 97 def title_and_last_names "#{title} #{people_names}" end |
#title_with_full_people_names ⇒ Object
101 102 103 |
# File 'lib/concerns/models/clip.rb', line 101 def title_with_full_people_names "#{title} with #{full_people_names}" end |
#topic_names ⇒ Object
105 106 107 |
# File 'lib/concerns/models/clip.rb', line 105 def topic_names topics.map{|topic| topic.name} end |
#video_switcher_params ⇒ Object
166 167 168 169 170 171 172 |
# File 'lib/concerns/models/clip.rb', line 166 def video_switcher_params video_switcher_params_hash = {:class => :clearfix} if !description.blank? video_switcher_params_hash.merge!({:rel=> :popover, :'data-content' => description, :'data-original-title' => title}) end video_switcher_params_hash end |
#vtt ⇒ Object
closed_captioning vtt file
151 152 153 |
# File 'lib/concerns/models/clip.rb', line 151 def vtt #closed_captioning vtt file siskel_path({:extension => 'vtt'}) end |
#webm ⇒ Object
147 148 149 |
# File 'lib/concerns/models/clip.rb', line 147 def webm siskel_path({:extension => 'webm'}) end |