Class: LibPtgBox::Catalog

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

Instance Method Summary collapse

Constructor Details

#initialize(product, complete_marc_file) ⇒ Catalog


7
8
9
10
11
12
# File 'app/modules/lib_ptg_box/catalog.rb', line 7

def initialize(product, complete_marc_file)
  @product = product
  @complete_marc_file = complete_marc_file
  @reader = MARC::XMLReader.new(StringIO.new(complete_marc_file.content))
  @marcs = @reader.entries.map { |entry| Unmarshaller::Marc.new(entry) }
end

Instance Method Details

#marc(doi) ⇒ Object


14
15
16
17
18
19
20
# File 'app/modules/lib_ptg_box/catalog.rb', line 14

def marc(doi)
  @marcs.each do |marc|
    next unless /#{doi}/i.match?(marc.doi)

    return marc
  end
end