Sha256: deec608c5bdd8e12fbc4a416fb75005af118fe5545c70275fa42bf8fc69349de

Contents?: true

Size: 1.27 KB

Versions: 76

Compression:

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

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

76 entries across 76 versions & 1 rubygems

Version Path
govuk_publishing_components-16.19.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.18.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.17.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.16.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.15.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.14.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.14.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.13.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.12.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.11.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.10.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.10.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.9.2 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.9.1 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.9.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.8.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.7.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.6.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.5.0 lib/govuk_publishing_components/presenters/schema_org.rb
govuk_publishing_components-16.4.0 lib/govuk_publishing_components/presenters/schema_org.rb