Sha256: 7bfc67c38d66c7c2c0307032334070941c5e4128af76f1a278d241f55a40c5de

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 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/how_to_schema'
require 'govuk_publishing_components/presenters/machine_readable/has_part_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'

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
        else
          raise "#{page.schema} is not supported"
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
govuk_publishing_components-10.0.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.28.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.27.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.26.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.26.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.25.0 lib/govuk_publishing_components/presenters/schema_org.rb