Sha256: 43274231b694fe138e10ca6554383e5351ddedb922dcfdd71428f0130a0295e0

Contents?: true

Size: 630 Bytes

Versions: 4

Compression:

Stored size: 630 Bytes

Contents

require 'json-schema'

module Fitting
  class Records
    class Unit
      class Combination
        attr_reader :description, :json_schema, :bodies

        def initialize(comb, bodies)
          @description = comb[1]
          @json_schema = comb[0]
          @bodies = bodies
        end

        def valid_bodies
          @valid_bodies ||= @bodies.inject([]) do |res, tested_body|
            next res unless JSON::Validator.validate(@json_schema, tested_body)

            res.push(tested_body)
          rescue JSON::Schema::UriError
            res.push(tested_body)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fitting-2.18.3 lib/fitting/records/unit/combination.rb
fitting-2.18.2 lib/fitting/records/unit/combination.rb
fitting-2.18.1 lib/fitting/records/unit/combination.rb
fitting-2.18.0 lib/fitting/records/unit/combination.rb