Sha256: 7138af9ae0f27771df9f69e484b0f3a80641b7ef894b1a45b05076bfde04178b

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

class DarwinCore
  class Metadata
    def initialize(archive = nil)
      @archive = archive
      @metadata = @archive.eml
    end

    def data
      @metadata
    end

    def id
      @metadata[:eml][:dataset][:attributes][:id] rescue nil
    end

    def package_id
      @metadata.data[:eml][:attributes][:packageId] rescue nil
    end

    def title
      @metadata[:eml][:dataset][:title] rescue nil
    end

    def authors
      return nil unless defined?(@metadata[:eml][:dataset][:creator])
      @metadata[:eml][:dataset][:creator] = 
        [@metadata[:eml][:dataset][:creator]] unless 
          @metadata[:eml][:dataset][:creator].class == Array 
      @metadata[:eml][:dataset][:creator].map do |c| 
        { first_name: c[:individualName][:givenName], 
          last_name: c[:individualName][:surName], 
          email: c[:electronicMailAddress] }
      end
    end

    def abstract
      @metadata[:eml][:dataset][:abstract] rescue nil
    end

    def citation
      @metadata[:eml][:additionalMetadata][:metadata][:citation] rescue nil
    end

    def url
      @metadata[:eml][:dataset][:distribution][:online][:url] rescue nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dwc-archive-0.9.11 lib/dwc-archive/metadata.rb
dwc-archive-0.9.10 lib/dwc-archive/metadata.rb