Sha256: e66a56cbe63a5f4744e5dea3ba78f59277b996baf2ccd7a7e309952047718a0c

Contents?: true

Size: 500 Bytes

Versions: 50

Compression:

Stored size: 500 Bytes

Contents

# frozen_string_literal: true

module Hako
  module Schema
    class OrderedArray
      def initialize(schema)
        @schema = schema
      end

      def valid?(object)
        object.is_a?(Array) && object.all? { |e| @schema.valid?(e) }
      end

      def same?(xs, ys)
        if xs.size != ys.size
          return false
        end

        xs.zip(ys) do |x, y|
          unless @schema.same?(x, y)
            return false
          end
        end
        true
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
hako-1.5.2 lib/hako/schema/ordered_array.rb
hako-1.5.1 lib/hako/schema/ordered_array.rb
hako-1.5.0 lib/hako/schema/ordered_array.rb
hako-1.4.0 lib/hako/schema/ordered_array.rb
hako-1.3.3 lib/hako/schema/ordered_array.rb
hako-1.3.2 lib/hako/schema/ordered_array.rb
hako-1.3.1 lib/hako/schema/ordered_array.rb
hako-1.3.0 lib/hako/schema/ordered_array.rb
hako-1.2.1 lib/hako/schema/ordered_array.rb
hako-1.2.0 lib/hako/schema/ordered_array.rb