Class: GovukPublishingComponents::Presenters::SchemaOrg
- Inherits:
-
Object
- Object
- GovukPublishingComponents::Presenters::SchemaOrg
- Defined in:
- lib/govuk_publishing_components/presenters/schema_org.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
-
#initialize(page) ⇒ SchemaOrg
constructor
A new instance of SchemaOrg.
- #schema_for_page ⇒ Object
- #structured_data ⇒ Object
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
#page ⇒ Object (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_page ⇒ Object
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_data ⇒ Object
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 |