Class: Nice::DataGouv::Dataset
- Inherits:
-
Object
- Object
- Nice::DataGouv::Dataset
- Defined in:
- lib/nice/data_gouv/dataset.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata_modified ⇒ Object
readonly
Returns the value of attribute metadata_modified.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Dataset
constructor
A new instance of Dataset.
- #to_h ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Dataset
Returns a new instance of Dataset.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nice/data_gouv/dataset.rb', line 9 def initialize(attributes = {}) @id = attributes['id'] @name = attributes['name'] @title = attributes['title'] @notes = attributes['notes'] @created_at = attributes['metadata_created'] @metadata_modified = attributes['metadata_modified'] @tags = (attributes['tags'] || []).map { |t| t.is_a?(Hash) ? t['name'] : t } @organization = if attributes['organization'] Organization.new(attributes['organization']) end @resources = (attributes['resources'] || []).map do |resource_data| Resource.new(resource_data) end end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
7 8 9 |
# File 'lib/nice/data_gouv/dataset.rb', line 7 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/nice/data_gouv/dataset.rb', line 7 def id @id end |
#metadata_modified ⇒ Object (readonly)
Returns the value of attribute metadata_modified.
7 8 9 |
# File 'lib/nice/data_gouv/dataset.rb', line 7 def @metadata_modified end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/nice/data_gouv/dataset.rb', line 7 def name @name end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
7 8 9 |
# File 'lib/nice/data_gouv/dataset.rb', line 7 def notes @notes end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
7 8 9 |
# File 'lib/nice/data_gouv/dataset.rb', line 7 def organization @organization end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
7 8 9 |
# File 'lib/nice/data_gouv/dataset.rb', line 7 def resources @resources end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
7 8 9 |
# File 'lib/nice/data_gouv/dataset.rb', line 7 def @tags end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/nice/data_gouv/dataset.rb', line 7 def title @title end |
Instance Method Details
#to_h ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nice/data_gouv/dataset.rb', line 27 def to_h { 'id' => @id, 'name' => @name, 'title' => @title, 'notes' => @notes, 'organization' => @organization&.to_h, 'resources' => @resources.map(&:to_h), 'tags' => @tags, 'created_at' => @created_at, 'metadata_modified' => @metadata_modified } end |