Class: OpenActive::DatasetSite::Settings
- Inherits:
-
Object
- Object
- OpenActive::DatasetSite::Settings
- Defined in:
- lib/openactive/dataset_site/settings.rb
Instance Attribute Summary collapse
-
#background_image_url ⇒ Object
Returns the value of attribute background_image_url.
-
#data_downloads ⇒ Array<OpenActive::Models::DataDownload>
An array of DataDownload objects.
-
#data_feed_types ⇒ Object
Returns the value of attribute data_feed_types.
-
#dataset_discussion_url ⇒ Object
Returns the value of attribute dataset_discussion_url.
-
#dataset_documentation_url ⇒ Object
Returns the value of attribute dataset_documentation_url.
-
#dataset_languages ⇒ Object
Returns the value of attribute dataset_languages.
-
#dataset_site_url ⇒ Object
Returns the value of attribute dataset_site_url.
-
#date_first_published ⇒ Object
Returns the value of attribute date_first_published.
-
#open_data_feed_base_url ⇒ Object
Returns the value of attribute open_data_feed_base_url.
-
#organisation_email ⇒ Object
Returns the value of attribute organisation_email.
-
#organisation_legal_entity ⇒ Object
Returns the value of attribute organisation_legal_entity.
-
#organisation_logo_url ⇒ Object
Returns the value of attribute organisation_logo_url.
-
#organisation_name ⇒ Object
Returns the value of attribute organisation_name.
-
#organisation_plain_text_description ⇒ Object
Returns the value of attribute organisation_plain_text_description.
-
#organisation_url ⇒ Object
Returns the value of attribute organisation_url.
-
#platform_name ⇒ Object
Returns the value of attribute platform_name.
-
#platform_software_version ⇒ Object
Returns the value of attribute platform_software_version.
-
#platform_url ⇒ Object
Returns the value of attribute platform_url.
Instance Method Summary collapse
- #booking_service ⇒ OpenActive::Models::BookingService?
-
#data_download(feed_type) ⇒ OpenActive::Models::DataDownload
A DataDownload object.
- #data_feed_descriptions ⇒ Object
- #data_feed_descriptions_sentence ⇒ Object
- #description ⇒ Object
-
#initialize(**params) ⇒ Settings
constructor
A new instance of Settings.
-
#keywords ⇒ Array<String>
An array of keywords.
- #name ⇒ Object
-
#to_dataset ⇒ Object
rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize(**params) ⇒ Settings
Returns a new instance of Settings.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/openactive/dataset_site/settings.rb', line 4 def initialize(**params) super() params.each do |k, v| setter_method = "#{k}=" raise ArgumentError, "Unrecognised field #{k}" unless respond_to?(setter_method) public_send(setter_method, v) end end |
Instance Attribute Details
#background_image_url ⇒ Object
Returns the value of attribute background_image_url.
30 31 32 |
# File 'lib/openactive/dataset_site/settings.rb', line 30 def background_image_url @background_image_url end |
#data_downloads ⇒ Array<OpenActive::Models::DataDownload>
Returns An array of DataDownload objects.
82 83 84 |
# File 'lib/openactive/dataset_site/settings.rb', line 82 def data_downloads @data_downloads end |
#data_feed_types ⇒ Object
Returns the value of attribute data_feed_types.
37 38 39 |
# File 'lib/openactive/dataset_site/settings.rb', line 37 def data_feed_types @data_feed_types end |
#dataset_discussion_url ⇒ Object
Returns the value of attribute dataset_discussion_url.
19 20 21 |
# File 'lib/openactive/dataset_site/settings.rb', line 19 def dataset_discussion_url @dataset_discussion_url end |
#dataset_documentation_url ⇒ Object
Returns the value of attribute dataset_documentation_url.
20 21 22 |
# File 'lib/openactive/dataset_site/settings.rb', line 20 def dataset_documentation_url @dataset_documentation_url end |
#dataset_languages ⇒ Object
Returns the value of attribute dataset_languages.
21 22 23 |
# File 'lib/openactive/dataset_site/settings.rb', line 21 def dataset_languages @dataset_languages end |
#dataset_site_url ⇒ Object
Returns the value of attribute dataset_site_url.
18 19 20 |
# File 'lib/openactive/dataset_site/settings.rb', line 18 def dataset_site_url @dataset_site_url end |
#date_first_published ⇒ Object
Returns the value of attribute date_first_published.
31 32 33 |
# File 'lib/openactive/dataset_site/settings.rb', line 31 def date_first_published @date_first_published end |
#open_data_feed_base_url ⇒ Object
Returns the value of attribute open_data_feed_base_url.
16 17 18 |
# File 'lib/openactive/dataset_site/settings.rb', line 16 def open_data_feed_base_url @open_data_feed_base_url end |
#organisation_email ⇒ Object
Returns the value of attribute organisation_email.
26 27 28 |
# File 'lib/openactive/dataset_site/settings.rb', line 26 def organisation_email @organisation_email end |
#organisation_legal_entity ⇒ Object
Returns the value of attribute organisation_legal_entity.
24 25 26 |
# File 'lib/openactive/dataset_site/settings.rb', line 24 def organisation_legal_entity @organisation_legal_entity end |
#organisation_logo_url ⇒ Object
Returns the value of attribute organisation_logo_url.
28 29 30 |
# File 'lib/openactive/dataset_site/settings.rb', line 28 def organisation_logo_url @organisation_logo_url end |
#organisation_name ⇒ Object
Returns the value of attribute organisation_name.
23 24 25 |
# File 'lib/openactive/dataset_site/settings.rb', line 23 def organisation_name @organisation_name end |
#organisation_plain_text_description ⇒ Object
Returns the value of attribute organisation_plain_text_description.
25 26 27 |
# File 'lib/openactive/dataset_site/settings.rb', line 25 def organisation_plain_text_description @organisation_plain_text_description end |
#organisation_url ⇒ Object
Returns the value of attribute organisation_url.
27 28 29 |
# File 'lib/openactive/dataset_site/settings.rb', line 27 def organisation_url @organisation_url end |
#platform_name ⇒ Object
Returns the value of attribute platform_name.
33 34 35 |
# File 'lib/openactive/dataset_site/settings.rb', line 33 def platform_name @platform_name end |
#platform_software_version ⇒ Object
Returns the value of attribute platform_software_version.
35 36 37 |
# File 'lib/openactive/dataset_site/settings.rb', line 35 def platform_software_version @platform_software_version end |
#platform_url ⇒ Object
Returns the value of attribute platform_url.
34 35 36 |
# File 'lib/openactive/dataset_site/settings.rb', line 34 def platform_url @platform_url end |
Instance Method Details
#booking_service ⇒ OpenActive::Models::BookingService?
87 88 89 90 91 92 93 94 95 |
# File 'lib/openactive/dataset_site/settings.rb', line 87 def booking_service return unless platform_name && !platform_name.empty? OpenActive::Models::BookingService.new( name: platform_name, url: platform_url, software_version: platform_software_version, ) end |
#data_download(feed_type) ⇒ OpenActive::Models::DataDownload
Returns A DataDownload object.
72 73 74 75 76 77 78 79 |
# File 'lib/openactive/dataset_site/settings.rb', line 72 def data_download(feed_type) OpenActive::Models::DataDownload.new( name: feed_type.name, additional_type: feed_type.same_as, encoding_format: OpenActive::DatasetSite::Meta::RPDE_MEDIA_TYPE, content_url: open_data_feed_base_url + feed_type.default_feed_path, ) end |
#data_feed_descriptions ⇒ Object
40 41 42 43 44 |
# File 'lib/openactive/dataset_site/settings.rb', line 40 def data_feed_descriptions data_feed_types.map do |description| description.respond_to?(:display_name) ? description.display_name : description end.uniq end |
#data_feed_descriptions_sentence ⇒ Object
50 51 52 |
# File 'lib/openactive/dataset_site/settings.rb', line 50 def data_feed_descriptions_sentence data_feed_descriptions.to_sentence.downcase end |
#description ⇒ Object
65 66 67 68 69 |
# File 'lib/openactive/dataset_site/settings.rb', line 65 def description "Near real-time availability and rich descriptions relating to the "\ "#{data_feed_descriptions_sentence} available from "\ "#{organisation_name}" end |
#keywords ⇒ Array<String>
Returns An array of keywords.
55 56 57 58 59 60 61 62 63 |
# File 'lib/openactive/dataset_site/settings.rb', line 55 def keywords [ *data_feed_descriptions, "Activities", "Sports", "Physical Activity", "OpenActive" ] end |
#name ⇒ Object
46 47 48 |
# File 'lib/openactive/dataset_site/settings.rb', line 46 def name "#{organisation_name} #{data_feed_descriptions.to_sentence}" end |
#to_dataset ⇒ Object
rubocop:disable Metrics/MethodLength
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/openactive/dataset_site/settings.rb', line 97 def to_dataset # rubocop:disable Metrics/MethodLength dataset = OpenActive::Models::Dataset.new( id: dataset_site_url, url: dataset_site_url, name: name, description: description, keywords: keywords, license: "https://creativecommons.org/licenses/by/4.0/", discussion_url: dataset_discussion_url, documentation: dataset_documentation_url, in_language: dataset_languages, schema_version: "https://www.openactive.io/modelling-opportunity-data/2.0/", publisher: OpenActive::Models::Organization.new( name: organisation_name, legal_name: organisation_legal_entity, description: organisation_plain_text_description, email: organisation_email, url: organisation_url, logo: OpenActive::Models::ImageObject.new( url: organisation_logo_url, ), ), date_modified: DateTime.now.new_offset(0), background_image: OpenActive::Models::ImageObject.new( url: background_image_url, ), distribution: data_downloads, date_published: date_first_published, ) if (booking_service_val = booking_service) dataset.booking_service = booking_service_val end dataset end |