Sha256: 604e26cfe134e3ca0be383ab8587383ef92223f43f751d22be4181feffad89a4

Contents?: true

Size: 1.93 KB

Versions: 21

Compression:

Stored size: 1.93 KB

Contents

require 'govuk_publishing_components/presenters/machine_readable/page'
require 'govuk_publishing_components/presenters/machine_readable/article_schema'
require 'govuk_publishing_components/presenters/machine_readable/creative_work_schema'
require 'govuk_publishing_components/presenters/machine_readable/faq_page_schema'
require 'govuk_publishing_components/presenters/machine_readable/government_service_schema'
require 'govuk_publishing_components/presenters/machine_readable/has_part_schema'
require 'govuk_publishing_components/presenters/machine_readable/is_part_of_schema'
require 'govuk_publishing_components/presenters/machine_readable/news_article_schema'
require 'govuk_publishing_components/presenters/machine_readable/organisation_schema'
require 'govuk_publishing_components/presenters/machine_readable/person_schema'
require 'govuk_publishing_components/presenters/machine_readable/potential_search_action_schema'
require 'govuk_publishing_components/presenters/machine_readable/search_results_page_schema'

module GovukPublishingComponents
  module Presenters
    class SchemaOrg
      attr_reader :page

      def initialize(page)
        @page = page
      end

      def structured_data
        if page.schema == :faq
          FaqPageSchema.new(page).structured_data
        elsif page.schema == :article
          ArticleSchema.new(page).structured_data
        elsif page.schema == :government_service
          GovernmentServiceSchema.new(page).structured_data
        elsif page.schema == :news_article
          NewsArticleSchema.new(page).structured_data
        elsif page.schema == :person
          PersonSchema.new(page).structured_data
        elsif page.schema == :organisation
          OrganisationSchema.new(page).structured_data
        elsif page.schema == :search_results_page
          SearchResultsPageSchema.new(page).structured_data
        else
          raise "#{page.schema} is not supported"
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
govuk_publishing_components-21.7.0 lib/govuk_publishing_components/presenters/schema_org.rb