Sha256: 89d1e67b62fe0cc9a6da33735e7b35327c9411748d857f2ce23b6ade778139ac

Contents?: true

Size: 1.57 KB

Versions: 44

Compression:

Stored size: 1.57 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/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 == :article
          ArticleSchema.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

44 entries across 44 versions & 1 rubygems

Version Path
govuk_publishing_components-20.0.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-19.0.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-18.3.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-18.3.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-18.2.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-18.1.2 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-18.1.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-18.1.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-18.0.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-18.0.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-17.21.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-17.20.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-17.19.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-17.19.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-17.18.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-17.17.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-17.16.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-17.15.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-17.14.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-17.13.0 lib/govuk_publishing_components/presenters/schema_org.rb