Class: LibPtgBox::Unmarshaller::Marc

Inherits:
Object
  • Object
show all
Defined in:
app/modules/lib_ptg_box/unmarshaller/marc.rb

Instance Method Summary collapse

Constructor Details

#initialize(entry) ⇒ Marc

Returns a new instance of Marc


6
7
8
# File 'app/modules/lib_ptg_box/unmarshaller/marc.rb', line 6

def initialize(entry)
  @entry = entry
end

Instance Method Details

#doiObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/modules/lib_ptg_box/unmarshaller/marc.rb', line 10

def doi
  @doi ||= begin
    @entry.fields.each do |field|
      next unless /^024$/i.match?(field.tag)
      next unless /^7$/i.match?(field.indicator1)

      field.subfields.each do |subfield|
        next unless /^a$/i.match?(subfield.code)

        return subfield.value
      end
    end
  end
end