lib/psulib_traject/macros.rb
# For genre facet and display
#
# limit to subfield $2 vocabularies for 655|*7 genres
For genre facet and display
limit to subfield $2 vocabularies for 655|*7 genres
For genre facet and display limit to subfield $2 vocabularies for 655| * 7 genres
def process_genre(fields)
      lambda do |record, accumulator|
        return nil unless record.is_a? MARC::Record
        genres = []
        vocabulary = %w[lcgft fast]
        Traject::MarcExtractor.cached(fields).collect_matching_lines(record) do |field, spec, extractor|
          genre = extractor.collect_subfields(field, spec).first
          include_genre = true
          unless genre.nil?
            if (field.tag == '655') && (field.indicator2 == '7')
              include_genre = vocabulary.include?(field['2'].to_s.downcase)
            end
            genres << Traject::Macros::Marc21.trim_punctuation(genre) if include_genre
          end
        end
        accumulator.replace(genres).uniq!
      end
    end
def process_genre ( fields ) lambda do | record , accumulator | return nil unless record . is_a? MARC :: Record genres = [ ] vocabulary = %w[ lcgft fast ] Traject :: MarcExtractor . cached ( fields ) . collect_matching_lines ( record ) do | field , spec , extractor | genre = extractor . collect_subfields ( field , spec ) . first include_genre = true unless genre . nil? if ( field . tag == '655' ) && ( field . indicator2 == '7' ) include_genre = vocabulary . include? ( field [ '2' ] . to_s . downcase ) end genres << Traject :: Macros :: Marc21 . trim_punctuation ( genre ) if include_genre end end accumulator . replace ( genres ) . uniq! end end
For genre facet and display
limit to subfield $2 vocabularies for 655|*7 genres
For genre facet and display limit to subfield $2 vocabularies for 655| * 7 genres
fields