Class: CharacterizeJob

Inherits:
Object
  • Object
show all
Defined in:
lib/sufia/jobs/characterize_job.rb

Overview

Copyright © 2012 The Pennsylvania State University

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(generic_file_id) ⇒ CharacterizeJob

Returns a new instance of CharacterizeJob.



23
24
25
# File 'lib/sufia/jobs/characterize_job.rb', line 23

def initialize(generic_file_id)
  self.generic_file_id = generic_file_id
end

Instance Attribute Details

#generic_fileObject

Returns the value of attribute generic_file.



21
22
23
# File 'lib/sufia/jobs/characterize_job.rb', line 21

def generic_file
  @generic_file
end

#generic_file_idObject

Returns the value of attribute generic_file_id.



21
22
23
# File 'lib/sufia/jobs/characterize_job.rb', line 21

def generic_file_id
  @generic_file_id
end

Instance Method Details

#after_characterizeObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/sufia/jobs/characterize_job.rb', line 33

def after_characterize
  if generic_file.pdf? || generic_file.image? || generic_file.video?
    generic_file.create_thumbnail
  end
  if generic_file.video?
    Sufia.queue.push(TranscodeVideoJob.new(generic_file_id, 'content'))
  elsif generic_file.audio?
    Sufia.queue.push(TranscodeAudioJob.new(generic_file_id, 'content'))
  end
end

#queue_nameObject



17
18
19
# File 'lib/sufia/jobs/characterize_job.rb', line 17

def queue_name
  :characterize
end

#runObject



27
28
29
30
31
# File 'lib/sufia/jobs/characterize_job.rb', line 27

def run
  self.generic_file = GenericFile.find(generic_file_id)
  generic_file.characterize
  after_characterize
end