Sha256: a0c4c6eea46ce7f24d186087909c42377612bc73d76df473662abd9d5c0f8690

Contents?: true

Size: 1.11 KB

Versions: 21

Compression:

Stored size: 1.11 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/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

21 entries across 21 versions & 1 rubygems

Version Path
govuk_publishing_components-9.24.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.23.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.22.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.21.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.20.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.19.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.18.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.17.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.17 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.16.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.16.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.15.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.14.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.13.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.12.2 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.12.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.12.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.11.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.10.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-9.9.1 lib/govuk_publishing_components/presenters/schema_org.rb