Module: Java::OrgMarc4j::MarcReader

Includes:
Enumerable, JLogger::Simple
Defined in:
lib/marc4j4r/reader.rb

Instance Method Summary collapse

Instance Method Details

#each(hashify = true) ⇒ Object

Return the next record, after calling #hashify on it



50
51
52
53
54
55
# File 'lib/marc4j4r/reader.rb', line 50

def each(hashify=true)
  while self.hasNext
    r = self.nextRecord(hashify)
    yield r
  end
end

#logErrorsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/marc4j4r/reader.rb', line 26

def logErrors
  return unless self.errors.getErrors
  self.errors.getErrors.each do |err|
    case err.severity
    when ErrorHandler::MAJOR_ERROR
      log.error err.toString
    when ErrorHandler::ERROR_TYPO, ErrorHandler::MINOR_ERROR
      self.log.warn err.toString
    when ErrorHandler::INFO
      log.info err.toString
    when ErrorHandler::FATAL
      log.error err.toString
      Process.exit
    end
  end
end

#nextRecord(hashify = true) ⇒ Object



43
44
45
46
47
# File 'lib/marc4j4r/reader.rb', line 43

def nextRecord(hashify = true)
  r = self.next
  r.hashify if hashify
  return r
end