Sha256: 77f84b5bee52718cec72160841513bf68df7595e34427d6314462f3d13bb1462

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

# typed: ignore
# frozen_string_literal: true

require 'date'
require 'schema_dot_org'
require 'schema_dot_org/person'
require 'schema_dot_org/place'

module SchemaDotOrg
  class Organization < SchemaType
    attr_accessor :email,
                  :founder,
                  :founding_date,
                  :founding_location,
                  :logo,
                  :name,
                  :url,
                  :same_as

    validates :email,             type: String
    validates :founder,           type: SchemaDotOrg::Person
    validates :founding_date,     type: Date
    validates :founding_location, type: SchemaDotOrg::Place
    validates :logo,              type: String
    validates :name,              type: String
    validates :url,               type: String
    validates :same_as,           type: Array, allow_nil: true

    def _to_json_struct
      {
        'name' => name,
        'email' => email,
        'url' => url,
        'logo' => logo,
        'founder' => founder.to_json_struct,
        'foundingDate' => founding_date.to_s,
        'foundingLocation' => founding_location.to_json_struct,
        'sameAs' => same_as
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
schema_dot_org-1.7.1 lib/schema_dot_org/organization.rb
schema_dot_org-1.7.0 lib/schema_dot_org/organization.rb