Module: Sufia::GenericFile::Characterization
- Extended by:
- ActiveSupport::Concern
- Included in:
- Sufia::GenericFile
- Defined in:
- lib/sufia/models/generic_file/characterization.rb
Instance Method Summary collapse
-
#append_metadata ⇒ Object
Populate descMetadata with fields from FITS (e.g. Author from pdfs).
- #characterization_terms ⇒ Object
-
#characterize ⇒ Object
Extract the metadata from the content datastream and record it in the characterization datastream.
- #characterize_if_changed ⇒ Object
- #duration ⇒ Object
- #height ⇒ Object
- #sample_rate ⇒ Object
- #width ⇒ Object
Instance Method Details
#append_metadata ⇒ Object
Populate descMetadata with fields from FITS (e.g. Author from pdfs)
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/sufia/models/generic_file/characterization.rb', line 58 def terms = self.characterization_terms Sufia.config.fits_to_desc_mapping.each_pair do |k, v| if terms.has_key?(k) # coerce to array to remove a conditional terms[k] = [terms[k]] unless terms[k].is_a? Array terms[k].each do |term_value| proxy_term = self.send(v) if proxy_term.kind_of?(Array) proxy_term << term_value unless proxy_term.include?(term_value) else # these are single-valued terms which cannot be appended to self.send("#{v}=", term_value) end end end end end |
#characterization_terms ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/sufia/models/generic_file/characterization.rb', line 77 def characterization_terms h = {} self.characterization.class.terminology.terms.each_pair do |k, v| next unless v.respond_to? :proxied_term term = v.proxied_term begin value = self.send(term.name) h[term.name] = value unless value.empty? rescue NoMethodError next end end h end |
#characterize ⇒ Object
Extract the metadata from the content datastream and record it in the characterization datastream
50 51 52 53 54 55 |
# File 'lib/sufia/models/generic_file/characterization.rb', line 50 def characterize self.characterization.ng_xml = self.content. self. self.filename = self.label save end |
#characterize_if_changed ⇒ Object
43 44 45 46 47 |
# File 'lib/sufia/models/generic_file/characterization.rb', line 43 def characterize_if_changed content_changed = self.content.changed? yield Sufia.queue.push(CharacterizeJob.new(self.pid)) if content_changed end |
#duration ⇒ Object
35 36 37 |
# File 'lib/sufia/models/generic_file/characterization.rb', line 35 def duration characterization.duration.blank? ? characterization.video_duration : characterization.duration end |
#height ⇒ Object
31 32 33 |
# File 'lib/sufia/models/generic_file/characterization.rb', line 31 def height characterization.height.blank? ? characterization.video_height : characterization.height end |
#sample_rate ⇒ Object
39 40 41 |
# File 'lib/sufia/models/generic_file/characterization.rb', line 39 def sample_rate characterization.sample_rate.blank? ? characterization.video_sample_rate : characterization.sample_rate end |
#width ⇒ Object
27 28 29 |
# File 'lib/sufia/models/generic_file/characterization.rb', line 27 def width characterization.width.blank? ? characterization.video_width : characterization.width end |