Class: GovukPublishingComponents::Presenters::GovernmentServiceSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_publishing_components/presenters/machine_readable/government_service_schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ GovernmentServiceSchema

Returns a new instance of GovernmentServiceSchema.



6
7
8
# File 'lib/govuk_publishing_components/presenters/machine_readable/government_service_schema.rb', line 6

def initialize(page)
  @page = page
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



4
5
6
# File 'lib/govuk_publishing_components/presenters/machine_readable/government_service_schema.rb', line 4

def page
  @page
end

Instance Method Details

#structured_dataObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/govuk_publishing_components/presenters/machine_readable/government_service_schema.rb', line 10

def structured_data
  # http://schema.org/GovernmentService
  {
    "@context" => "http://schema.org",
    "@type" => "GovernmentService",
    "name" => page.title,
    "description" => page.description,
    "url" => page.canonical_url,
  }
    .merge(provider)
    .merge(related_services)
end