Class: Puree::Dataset
Overview
Dataset resource
Instance Method Summary collapse
-
#access ⇒ String
Open access permission.
-
#available ⇒ Hash
Date made available.
-
#description ⇒ Array<String>
Description.
-
#doi ⇒ String
Digital Object Identifier.
-
#file ⇒ Array<Hash>
Supporting file.
-
#geographical ⇒ Array<String>
Geographical coverage.
-
#initialize ⇒ Dataset
constructor
A new instance of Dataset.
-
#keyword ⇒ Array<String>
Keyword.
-
#metadata ⇒ Hash
All metadata.
-
#person ⇒ Hash<Array, Array>
Person, internal and external.
-
#publication ⇒ Array<Hash>
Publication.
-
#temporal ⇒ Hash
Temporal coverage.
-
#title ⇒ Array<String>
Title.
Methods inherited from Resource
#content, #get, #response, #set_content
Constructor Details
#initialize ⇒ Dataset
Returns a new instance of Dataset.
7 8 9 |
# File 'lib/puree/dataset.rb', line 7 def initialize super(:dataset) end |
Instance Method Details
#access ⇒ String
Open access permission
159 160 161 162 |
# File 'lib/puree/dataset.rb', line 159 def access data = node 'openAccessPermission' !data.nil? && !data.empty? ? data['term']['localizedString']["__content__"] : '' end |
#available ⇒ Hash
Date made available
120 121 122 123 |
# File 'lib/puree/dataset.rb', line 120 def available data = node('dateMadeAvailable') Puree::Date.normalise(data) end |
#description ⇒ Array<String>
Description
40 41 42 43 44 45 46 47 48 |
# File 'lib/puree/dataset.rb', line 40 def description data = node 'descriptions' if !data.nil? && !data.empty? data = data['classificationDefinedField']['value']['localizedString']['__content__'].tr("\n", '') data.is_a?(Array) ? data : data.split(',') else [] end end |
#doi ⇒ String
Digital Object Identifier
211 212 213 214 |
# File 'lib/puree/dataset.rb', line 211 def doi data = node 'doi' !data.nil? && !data.empty? ? data['doi'] : '' end |
#file ⇒ Array<Hash>
Supporting file
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/puree/dataset.rb', line 168 def file data = node 'documents' docs = [] if !data.nil? && !data.empty? # convert to array data_arr = [] if data['document'].is_a?(Array) data_arr = data['document'] else data_arr << data['document'] end data_arr.each do |d| doc = {} # doc['id'] = d['id'] doc['name'] = d['fileName'] doc['mime'] = d['mimeType'] doc['size'] = d['size'] doc['url'] = d['url'] doc['title'] = d['title'] # doc['createdDate'] = doc['createdDate'] # doc['visibleOnPortalDate'] = doc['visibleOnPortalDate'] # doc['limitedVisibility'] = doc['limitedVisibility'] license = {} if d['documentLicense'] license_name = d['documentLicense']['term']['localizedString']['__content__'] license['name'] = license_name license_url = d['documentLicense']['description']['localizedString']['__content__'] license['url'] = license_url doc['license'] = license end docs << doc end end docs end |
#geographical ⇒ Array<String>
Geographical coverage
128 129 130 131 132 133 134 135 136 |
# File 'lib/puree/dataset.rb', line 128 def geographical data = node 'geographicalCoverage' if !data.nil? && !data.empty? data = data['localizedString']["__content__"] data.is_a?(Array) ? data : data.split(',') else [] end end |
#keyword ⇒ Array<String>
Keyword
27 28 29 30 31 32 33 34 35 |
# File 'lib/puree/dataset.rb', line 27 def keyword data = node 'keywordGroups' if !data.nil? && !data.empty? data = data['keywordGroup']['keyword']['userDefinedKeyword']['freeKeyword'] data.is_a?(Array) ? data : data.split(',') else [] end end |
#metadata ⇒ Hash
All metadata
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/puree/dataset.rb', line 225 def o = {} o['title'] = title o['description'] = description o['keyword'] = keyword o['person'] = person o['temporal'] = temporal o['geographical'] = geographical o['file'] = file o['publication'] = publication o['available'] = available o['access'] = access o['doi'] = doi o end |
#person ⇒ Hash<Array, Array>
Person, internal and external
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/puree/dataset.rb', line 53 def person data = node('persons') persons = {} if !data.nil? && !data.empty? data = data['dataSetPersonAssociation'] else return persons end internal_persons = [] external_persons = [] case data when Array data.each do |d| person = generic_person d if d.key? 'person' person['uuid'] = d['person']['uuid'] internal_persons << person end if d.key? 'externalPerson' person['uuid'] = d['externalPerson']['uuid'] external_persons << person end end when Hash person = generic_person data if data.key? 'person' person['uuid'] = data['person']['uuid'] internal_persons << person end if data.key? 'externalPerson' person['uuid'] = data['externalPerson']['uuid'] external_persons << person end end persons['internal'] = internal_persons persons['external'] = external_persons persons end |
#publication ⇒ Array<Hash>
Publication
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/puree/dataset.rb', line 95 def publication data = node('relatedPublications') publications = [] if !data.nil? && !data.empty? # convert to array data_arr = [] if data['relatedContent'].is_a?(Array) data_arr = data['relatedContent'] else data_arr[0] = data['relatedContent'] end data_arr.each do |d| o = {} o['type'] = d['typeClassification'] o['title'] = d['title'] o['uuid'] = d['uuid'] publications << o end end publications end |
#temporal ⇒ Hash
Temporal coverage
141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/puree/dataset.rb', line 141 def temporal data = {} data['start'] = {} data['end'] = {} start_date = temporal_coverage_start_date if !start_date.nil? && !start_date.empty? data['start'] = start_date end end_date = temporal_coverage_end_date if !end_date.nil? && !end_date.empty? data['end'] = end_date end data end |
#title ⇒ Array<String>
Title
14 15 16 17 18 19 20 21 22 |
# File 'lib/puree/dataset.rb', line 14 def title data = node 'title' if !data.nil? && !data.empty? data = data['localizedString']["__content__"] data.is_a?(Array) ? data : data.split(',') else [] end end |