Class: Krikri::Enrichments::GenreFilter
- Inherits:
-
Object
- Object
- Krikri::Enrichments::GenreFilter
- Includes:
- Audumbla::FieldEnrichment
- Defined in:
- lib/krikri/enrichments/genre_filter.rb
Overview
Enrichment to remove non-genre fields from
StripHtml.new.enrich_value('Book') => 'Book'
StripHtml.new.enrich_value('not a book') => nil
Allowed genre terms are:
- Book
- Film/Video
- Manuscript
- Maps
- Music
- Musical Score
- Newspapers
- Nonmusic
- Photograph/Pictorial Works
- Serial
Removes all non-string values
Constant Summary collapse
- TERMS =
['Book', 'Film/Video', 'Manuscript', 'Maps', 'Music', 'Musical Score', 'Newspapers', 'Nonmusic', 'Photograph/Pictorial Works', 'Serial']
Instance Method Summary collapse
Instance Method Details
#enrich_value(value) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/krikri/enrichments/genre_filter.rb', line 36 def enrich_value(value) return nil unless value.is_a? String term = TERMS.select do |t| t.downcase.gsub(/[^a-zA-Z]/, '') == value.downcase.gsub(/[^a-zA-Z]/, '') end term.empty? ? nil : term.first end |