Sha256: 5f4faa3d7f15bece76b98ea30233c613cebe362f69e6f54da02c90121b4ba6ec
Contents?: true
Size: 1.48 KB
Versions: 6
Compression:
Stored size: 1.48 KB
Contents
# marc4j4r -- work with marc4j in JRuby marc4j4r is some simple syntactic sugar on top of the java libary [marc4j](http://marc4j.tigris.org/). It allows iteration via #each and implements many of the same convenience functions as [ruby-marc](http://marc.rubyforge.org/). Most of the good stuff is in RecordImpl and DataFieldImpl. They, along with the *Reader classes, now implement #each for their subparts as well as #[] where it makes sense. See the examples in [the documentation]() for more information. There's also a convenience module method, MARC4J4R.reader, to get a reader, as shown below. Full documentation can be generated via the 'rake yard' command and is online at http://rdoc.info/projects/billdueber/marc4j4r ## Example require 'rubygems' require 'marc4j4r' reader = MARC4J4R.reader('test.mrc') #reader = MARC4J4R.reader('test.mrc', :strictmarc) # be explicit #preader = MARC4J4R.reader('test.mrc', :permissivemarc) #xmlreader = MARC4J4R.reader('test.xml', :marcxml) # # Can also use an IO object # reader = MARC4J4R.reader(File.new('test.mrc')) reader.each do |r| lccn = r['010']['a'] if r['010'] isSBns = r.find_by_tag(['020', '022']).map {|f| f['a']} first035 = r['035'] fullTitle = r['245'].sub_values(['a', 'b', 'd', 'f', 'h']).join(' ') r['300'].each do |subfield| puts subfield.code + ' ' + subfield.value end end == Copyright Copyright (c) 2010 BillDueber. See LICENSE for details.
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
marc4j4r-0.1.6 | README.markdown |
marc4j4r-0.1.5 | README.markdown |
marc4j4r-0.1.4 | README.markdown |
marc4j4r-0.1.3 | README.markdown |
marc4j4r-0.1.2 | README.markdown |
marc4j4r-0.1.0 | README.markdown |