Sha256: f900751ce1c6fbacf25876152002d3c077a14c3f16fb507bd4da8b30b35d4edd

Contents?: true

Size: 810 Bytes

Versions: 2

Compression:

Stored size: 810 Bytes

Contents

# frozen_string_literal: true

require 'schema_dot_org'
require 'schema_dot_org/product'


module SchemaDotOrg
  # Model the Schema.org `ItemListElement`.  See https://schema.org/ItemListElement
  class ListItem < SchemaType
    attr_accessor :position, :item,
                  :url, :name, :image

    validates :position,      type: Integer, presence: true
    validates :url,           type: String, allow_nil: true
    validates :name,          type: String, allow_nil: true
    validates :image,         type: String, allow_nil: true

    validates :item,         type: Product, allow_nil: true

    def _to_json_struct
      {
        'position' => position,
        'url' => url,
        'name' => name,
        'image' => image,
        'item' => object_to_json_struct(item)
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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