Class: Kiba::Extend::Sources::Marc
- Inherits:
-
Object
- Object
- Kiba::Extend::Sources::Marc
- Extended by:
- Sourceable
- Defined in:
- lib/kiba/extend/sources/marc.rb
Overview
Only transforms in the Kiba::Extend::Transforms::Marc
namespace
can initially be used on records from this source
The class name is Marc
instead of MARC
because the ruby-marc
gem already has the MARC
namespace
Given a binary MARC file containing one or more MARC records, yields one MARC record at a time, for processing.
This is just a simple wrapper around ruby-marc
’s MARC::Reader
:each
method. See that class’ documentation at
https://github.com/ruby-marc/ruby-marc/blob/main/lib/marc/reader.rb
for more details about args that can be passed in to deal with
character encoding.
See File Registry Entry documentation page for more details on how to set up a Marc source in a project.
Class Method Summary collapse
Instance Method Summary collapse
-
#each ⇒ Object
-
#initialize(filename:, args: nil) ⇒ Marc
constructor
A new instance of Marc.
Methods included from Sourceable
Methods included from Registry::Fileable
#default_args, #default_file_options, #labeled_options, #options_key, #path_key, #requires_path?
Constructor Details
#initialize(filename:, args: nil) ⇒ Marc
Returns a new instance of Marc.
51 52 53 54 55 56 57 |
# File 'lib/kiba/extend/sources/marc.rb', line 51 def initialize(filename:, args: nil) @args = if args [filename, args] else [filename] end end |
Class Method Details
.default_file_options ⇒ Object
29 30 31 |
# File 'lib/kiba/extend/sources/marc.rb', line 29 def nil end |
.options_key ⇒ Object
33 34 35 |
# File 'lib/kiba/extend/sources/marc.rb', line 33 def :args end |
.path_key ⇒ Object
37 38 39 |
# File 'lib/kiba/extend/sources/marc.rb', line 37 def path_key :filename end |
.requires_path? ⇒ Boolean
41 42 43 |
# File 'lib/kiba/extend/sources/marc.rb', line 41 def requires_path? true end |
Instance Method Details
#each ⇒ Object
59 60 61 62 63 |
# File 'lib/kiba/extend/sources/marc.rb', line 59 def each MARC::Reader.new(*args).each do |record| yield(record) end end |