Sha256: 3ec293118a4815c6698a3e8ed7080d3d9dc861b20d7460312685f54791f143cc

Contents?: true

Size: 913 Bytes

Versions: 2

Compression:

Stored size: 913 Bytes

Contents

# frozen_string_literal: true

require 'date'
require 'schema_dot_org'
require 'schema_dot_org/aggregate_offer'

# Model the Schema.org `Thing > Place`.  See https://schema.org/Product
#
module SchemaDotOrg
  class Product < SchemaType
    attr_accessor :name,
                  :url,
                  :description,
                  :image,
                  :offers

    validates :name,              type: String
    validates :url,               type: String
    validates :description,       type: String, allow_nil: true
    validates :image,             type: Array, allow_nil: true
    validates :offers,            type: SchemaDotOrg::AggregateOffer

    def _to_json_struct
      {
        "name" => name,
        "url" => url,
        "description" => description,
        "image" => image,
        "offers" => offers.to_json_struct
      }
    end

    def image
      @image || []
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
schema_dot_org-2.1 lib/schema_dot_org/product.rb
schema_dot_org-2.0 lib/schema_dot_org/product.rb