Class: Ezid::Batch
Instance Attribute Summary collapse
-
#batch_file ⇒ Object
readonly
Returns the value of attribute batch_file.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #each_anvl(&block) ⇒ Object
- #each_csv ⇒ Object
- #each_xml ⇒ Object
-
#initialize(format, batch_file) ⇒ Batch
constructor
A new instance of Batch.
Constructor Details
#initialize(format, batch_file) ⇒ Batch
Returns a new instance of Batch.
7 8 9 10 |
# File 'lib/ezid/batch.rb', line 7 def initialize(format, batch_file) @format = format @batch_file = batch_file end |
Instance Attribute Details
#batch_file ⇒ Object (readonly)
Returns the value of attribute batch_file.
5 6 7 |
# File 'lib/ezid/batch.rb', line 5 def batch_file @batch_file end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
5 6 7 |
# File 'lib/ezid/batch.rb', line 5 def format @format end |
Instance Method Details
#each(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ezid/batch.rb', line 12 def each(&block) case format when :anvl each_anvl(&block) when :xml each_xml(&block) when :csv each_csv(&block) end end |
#each_anvl(&block) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/ezid/batch.rb', line 23 def each_anvl(&block) File.open(batch_file, "rb") do |f| while record = f.gets("") head, = record.split(/\n/, 2) id = head.sub(/\A::/, "").strip yield Identifier.load(id, ) end end end |
#each_csv ⇒ Object
37 38 39 |
# File 'lib/ezid/batch.rb', line 37 def each_csv raise NotImplementedError end |
#each_xml ⇒ Object
33 34 35 |
# File 'lib/ezid/batch.rb', line 33 def each_xml raise NotImplementedError end |