Class: Kiba::Extend::Transforms::Marc::ExtractSubfieldsFromField
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::Marc::ExtractSubfieldsFromField
- Includes:
- FieldLinkable
- Defined in:
- lib/kiba/extend/transforms/marc/extract_subfields_from_field.rb
Overview
For each occurrence of given field tag, outputs a row with the following columns: marcid, fullfield, and one column per specified subfield. If there are more than one occurrnces of a subfield within a given field, the multiple values are separated by the delim value
Instance Method Summary collapse
-
#initialize(tag:, subfields:, indicators: false, id_target: Kiba::Extend::Marc.id_target_field, delim: Kiba::Extend.delim) ⇒ ExtractSubfieldsFromField
constructor
A new instance of ExtractSubfieldsFromField.
-
#process(record) {|row| ... } ⇒ Object
Methods included from FieldLinkable
Constructor Details
#initialize(tag:, subfields:, indicators: false, id_target: Kiba::Extend::Marc.id_target_field, delim: Kiba::Extend.delim) ⇒ ExtractSubfieldsFromField
Returns a new instance of ExtractSubfieldsFromField.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/kiba/extend/transforms/marc/extract_subfields_from_field.rb', line 63 def initialize(tag:, subfields:, indicators: false, id_target: Kiba::Extend::Marc.id_target_field, delim: Kiba::Extend.delim) @tag = tag @subfields = subfields @indicators = indicators @id_target = id_target @delim = delim @idextractor = Kiba::Extend::Utils::MarcIdExtractor.new end |
Instance Method Details
#process(record) {|row| ... } ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/kiba/extend/transforms/marc/extract_subfields_from_field.rb', line 76 def process(record) fields = select_fields(record, [tag]) .reject { |fld| fld.codes.intersection(subfields).empty? } return nil if fields.empty? idhash = {id_target => idextractor.call(record)} prepare_rows(fields, idhash).each do |row| yield row end nil end |