Sha256: bdf2e655cc0361cfdea68a062cc433f0f7ff40650014db0820cf19fa38afc054

Contents?: true

Size: 906 Bytes

Versions: 2

Compression:

Stored size: 906 Bytes

Contents

# frozen_string_literal: true

require 'date'
require 'schema_dot_org'
require 'schema_dot_org/offer'

# Model the Schema.org `Thing > Place`.  See https://schema.org/Offer
#
module SchemaDotOrg
  class AggregateOffer < SchemaType
    attr_accessor :priceCurrency,
                  :highPrice,
                  :lowPrice,
                  :offerCount,
                  :offers

    validates :lowPrice,       type: Numeric
    validates :highPrice,      type: Numeric, allow_nil: true
    validates :offerCount,     type: String, allow_nil: true
    validates :offers,         type: Array, allow_nil: true

    def _to_json_struct
      {
        "priceCurrency" => priceCurrency,
        "lowPrice" => lowPrice,
        "highPrice" => highPrice,
        "offerCount" => offerCount,
        "offers" => offers.map(&:to_json_struct)
      }
    end

    def offers
      @offers || []
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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