Class: DPN::Bagit::Bag::DPNInfoTxt
- Inherits:
-
Object
- Object
- DPN::Bagit::Bag::DPNInfoTxt
- Defined in:
- lib/dpn/bagit/bag/dpn_info_txt.rb
Overview
A wrapper for the dpn-info.txt file within the bag. Once created, it does not change with changes made to the underlying txt file; in that case, a new Bag should be created.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Get the value associated with the given field.
-
#getErrors ⇒ Array<String]
Returns a list of any errors encountered on creation and validation.
-
#initialize(opts) ⇒ DPNInfoTxt
constructor
A new instance of DPNInfoTxt.
-
#valid? ⇒ Boolean
Check for validity.
Constructor Details
#initialize(file_location) ⇒ DPNInfoTxt #initialize(opts) ⇒ DPNInfoTxt
Returns a new instance of DPNInfoTxt.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dpn/bagit/bag/dpn_info_txt.rb', line 26 def initialize(opts) @settings = DPN::Bagit::Settings.instance.config @dpnInfoKeysArrays = @settings[:bag][:dpn_info][:arrays] @dpnInfoKeysNonArrays = @settings[:bag][:dpn_info][:non_arrays] @dpnInfoErrors = [] @dpnInfo = {} if opts.is_a? String self.from_existing(opts) else self.build(opts) end end |
Instance Method Details
#[](key) ⇒ Object
Get the value associated with the given field.
56 57 58 |
# File 'lib/dpn/bagit/bag/dpn_info_txt.rb', line 56 def [](key) return @dpnInfo[key.to_sym] end |
#getErrors ⇒ Array<String]
Returns a list of any errors encountered on creation and validation.
49 50 51 |
# File 'lib/dpn/bagit/bag/dpn_info_txt.rb', line 49 def getErrors() return @dpnInfoErrors end |
#valid? ⇒ Boolean
Check for validity
42 43 44 |
# File 'lib/dpn/bagit/bag/dpn_info_txt.rb', line 42 def valid? return @dpnInfoErrors.empty? end |