Sha256: 4e071ce3a9392abf8a958a55d595166539f37cfe41ab12ee205a2f870ba271a7

Contents?: true

Size: 1.09 KB

Versions: 15

Compression:

Stored size: 1.09 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 {|c| {:first_name => c[:individualName][:givenName], :last_name => c[:individualName][:surName], :email => c[:electronicMailAddress]}}
    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

15 entries across 15 versions & 1 rubygems

Version Path
dwc-archive-0.9.6 lib/dwc-archive/metadata.rb
dwc-archive-0.9.5 lib/dwc-archive/metadata.rb
dwc-archive-0.9.4 lib/dwc-archive/metadata.rb
dwc-archive-0.9.3 lib/dwc-archive/metadata.rb
dwc-archive-0.9.2 lib/dwc-archive/metadata.rb
dwc-archive-0.9.1 lib/dwc-archive/metadata.rb
dwc-archive-0.9.0 lib/dwc-archive/metadata.rb
dwc-archive-0.8.3 lib/dwc-archive/metadata.rb
dwc-archive-0.8.2 lib/dwc-archive/metadata.rb
dwc-archive-0.8.1 lib/dwc-archive/metadata.rb
dwc-archive-0.8.0 lib/dwc-archive/metadata.rb
dwc-archive-0.7.18 lib/dwc-archive/metadata.rb
dwc-archive-0.7.17 lib/dwc-archive/metadata.rb
dwc-archive-0.7.16 lib/dwc-archive/metadata.rb
dwc-archive-0.7.15 lib/dwc-archive/metadata.rb