Class: GovukPublishingComponents::Presenters::SchemaOrg

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ SchemaOrg

Returns a new instance of SchemaOrg.



21
22
23
# File 'lib/govuk_publishing_components/presenters/schema_org.rb', line 21

def initialize(page)
  @page = page
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



19
20
21
# File 'lib/govuk_publishing_components/presenters/schema_org.rb', line 19

def page
  @page
end

Instance Method Details

#schema_for_pageObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/govuk_publishing_components/presenters/schema_org.rb', line 29

def schema_for_page
  case page.schema
  when :faq
    FaqPageSchema
  when :article
    ArticleSchema
  when :government_service
    GovernmentServiceSchema
  when :news_article
    NewsArticleSchema
  when :person
    PersonSchema
  when :organisation
    OrganisationSchema
  when :search_results_page
    SearchResultsPageSchema
  when :dataset
    DatasetSchema
  when :html_publication
    HtmlPublicationSchema
  else
    raise "#{page.schema} is not supported"
  end
end

#structured_dataObject



25
26
27
# File 'lib/govuk_publishing_components/presenters/schema_org.rb', line 25

def structured_data
  schema_for_page.new(page).structured_data
end