Class: DarwinCore::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/dwc_archive/metadata.rb

Overview

Represents data from EML (Ecological Metadata Language) file

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(archive = nil) ⇒ Metadata

Returns a new instance of Metadata.


9
10
11
12
# File 'lib/dwc_archive/metadata.rb', line 9

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

Instance Attribute Details

#metadataObject (readonly) Also known as: data

Returns the value of attribute metadata


6
7
8
# File 'lib/dwc_archive/metadata.rb', line 6

def 
  @metadata
end

Instance Method Details

#abstractObject


36
37
38
# File 'lib/dwc_archive/metadata.rb', line 36

def abstract
  fix_nil { @metadata[:eml][:dataset][:abstract] }
end

#authorsObject


26
27
28
29
30
31
32
33
34
# File 'lib/dwc_archive/metadata.rb', line 26

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

#citationObject


40
41
42
# File 'lib/dwc_archive/metadata.rb', line 40

def citation
  fix_nil { @metadata[:eml][:additionalMetadata][:metadata][:citation] }
end

#idObject


14
15
16
# File 'lib/dwc_archive/metadata.rb', line 14

def id
  fix_nil { @metadata[:eml][:dataset][:attributes][:id] }
end

#package_idObject


18
19
20
# File 'lib/dwc_archive/metadata.rb', line 18

def package_id
  fix_nil { @metadata.data[:eml][:attributes][:packageId] }
end

#titleObject


22
23
24
# File 'lib/dwc_archive/metadata.rb', line 22

def title
  fix_nil { @metadata[:eml][:dataset][:title] }
end

#urlObject


44
45
46
# File 'lib/dwc_archive/metadata.rb', line 44

def url
  fix_nil { @metadata[:eml][:dataset][:distribution][:online][:url] }
end