Sha256: 34b727f9270e2ad16475f851f2a4449cd49c96871d9228cf9447f762b6ff4547
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true class DarwinCore # Represents data from EML (Ecological Metadata Language) file class Metadata attr_reader :metadata alias data metadata def initialize(archive = nil) @archive = archive @metadata = @archive.eml end def id fix_nil { @metadata[:eml][:dataset][:attributes][:id] } end def package_id fix_nil { @metadata.data[:eml][:attributes][:packageId] } end def title fix_nil { @metadata[:eml][:dataset][:title] } end def authors return nil unless defined?(@metadata[:eml][:dataset][:creator]) authors = [@metadata[:eml][:dataset][:creator]].flatten authors.map do |au| { first_name: au[:individualName][:givenName], last_name: au[:individualName][:surName], email: au[:electronicMailAddress] } end end def abstract fix_nil { @metadata[:eml][:dataset][:abstract] } end def citation fix_nil { @metadata[:eml][:additionalMetadata][:metadata][:citation] } end def url fix_nil { @metadata[:eml][:dataset][:distribution][:online][:url] } end private def fix_nil yield rescue NoMethodError nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dwc-archive-1.1.1 | lib/dwc_archive/metadata.rb |
dwc-archive-1.1.0 | lib/dwc_archive/metadata.rb |
dwc-archive-1.0.1 | lib/dwc_archive/metadata.rb |