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

Instance Method Details

#chaptersObject

vtt file



155
156
# File 'lib/concerns/models/clip.rb', line 155

def chapters #vtt file
end

#duration_iso8601Object



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_prettyObject



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_namesObject



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

#mp4Object



143
144
145
# File 'lib/concerns/models/clip.rb', line 143

def mp4
  siskel_path({:extension => 'mp4'})
end

#pdf_transcriptObject



158
159
160
# File 'lib/concerns/models/clip.rb', line 158

def pdf_transcript
  siskel_path({suffix: '-transcript', extension: 'pdf'})
end

#people_namesObject



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_titleObject



109
110
111
# File 'lib/concerns/models/clip.rb', line 109

def people_with_title
  "#{people_names}: #{title}"
end

#pngObject



139
140
141
# File 'lib/concerns/models/clip.rb', line 139

def png
  siskel_path({:extension => 'png'})
end


193
194
195
196
# File 'lib/concerns/models/clip.rb', line 193

def related_topic_clips
  # FIXME: this could probably done in one nice query
  topics.map{|topic| topic.clips}.flatten.uniq - [self]
end

#should_generate_new_friendly_id?Boolean

Returns:

  • (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_transcriptObject



162
163
164
# File 'lib/concerns/models/clip.rb', line 162

def text_transcript
  siskel_path({suffix: '-transcript', extension: 'txt'})
end

#title_and_filenameObject

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_namesObject



97
98
99
# File 'lib/concerns/models/clip.rb', line 97

def title_and_last_names
  "#{title} #{people_names}"
end

#title_with_full_people_namesObject



101
102
103
# File 'lib/concerns/models/clip.rb', line 101

def title_with_full_people_names
  "#{title} with #{full_people_names}"
end

#topic_namesObject



105
106
107
# File 'lib/concerns/models/clip.rb', line 105

def topic_names
  topics.map{|topic| topic.name}
end

#video_switcher_paramsObject



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

#vttObject

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

#webmObject



147
148
149
# File 'lib/concerns/models/clip.rb', line 147

def webm
  siskel_path({:extension => 'webm'})
end