Class: DarwinCore::Archive
- Inherits:
-
Object
- Object
- DarwinCore::Archive
- Defined in:
- lib/dwc-archive/archive.rb
Instance Attribute Summary collapse
-
#eml ⇒ Object
readonly
Returns the value of attribute eml.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Instance Method Summary collapse
- #clean ⇒ Object
- #files ⇒ Object
- #files_path ⇒ Object
-
#initialize(archive_path, tmp_dir) ⇒ Archive
constructor
A new instance of Archive.
- #valid? ⇒ Boolean
Constructor Details
#initialize(archive_path, tmp_dir) ⇒ Archive
Returns a new instance of Archive.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dwc-archive/archive.rb', line 5 def initialize(archive_path, tmp_dir) @archive_path = archive_path @tmp_dir = tmp_dir @expander = DarwinCore::Expander.new(@archive_path, @tmp_dir) @expander.unpack if valid? @meta = DarwinCore::XmlReader.from_xml(open(File.join(@expander.path, 'meta.xml'))) @eml = files.include?("eml.xml") ? DarwinCore::XmlReader.from_xml(open(File.join(@expander.path, 'eml.xml'))) : nil else clean raise InvalidArchiveError end end |
Instance Attribute Details
#eml ⇒ Object (readonly)
Returns the value of attribute eml.
4 5 6 |
# File 'lib/dwc-archive/archive.rb', line 4 def eml @eml end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
4 5 6 |
# File 'lib/dwc-archive/archive.rb', line 4 def @meta end |
Instance Method Details
#clean ⇒ Object
33 34 35 |
# File 'lib/dwc-archive/archive.rb', line 33 def clean @expander.clean end |
#files ⇒ Object
25 26 27 |
# File 'lib/dwc-archive/archive.rb', line 25 def files @expander.files end |
#files_path ⇒ Object
29 30 31 |
# File 'lib/dwc-archive/archive.rb', line 29 def files_path @expander.path end |
#valid? ⇒ Boolean
19 20 21 22 23 |
# File 'lib/dwc-archive/archive.rb', line 19 def valid? valid = true valid = valid && @expander.path && FileTest.exists?(@expander.path) valid = valid && files && files.include?('meta.xml') end |