class Speculation::PredicateSpec
@private
Constants
- S
This is a Ruby translation of clojure.spec:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec.clj
All credit belongs with Rich Hickey and contributors for their original work.
This is a Ruby translation of clojure.spec:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec.clj
All credit belongs with Rich Hickey and contributors for their original work.
This is a Ruby translation of clojure.spec:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec.clj
All credit belongs with Rich Hickey and contributors for their original work.
This is a Ruby translation of clojure.spec:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec.clj
All credit belongs with Rich Hickey and contributors for their original work.
This is a Ruby translation of clojure.spec:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec.clj
All credit belongs with Rich Hickey and contributors for their original work.
This is a Ruby translation of clojure.spec:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec.clj
All credit belongs with Rich Hickey and contributors for their original work.
This is a Ruby translation of clojure.spec:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec.clj
All credit belongs with Rich Hickey and contributors for their original work.
This is a Ruby translation of clojure.spec:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec.clj
All credit belongs with Rich Hickey and contributors for their original work.
This is a Ruby translation of clojure.spec:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec.clj
All credit belongs with Rich Hickey and contributors for their original work.
Public Class Methods
# File lib/speculation/spec/predicate_spec.rb, line 13 def initialize(predicate, should_conform, gen, unconformer) @predicate = predicate @should_conform = should_conform @gen = gen @unconformer = unconformer end
Public Instance Methods
# File lib/speculation/spec/predicate_spec.rb, line 20 def conform(value) ret = case @predicate when Set then @predicate.include?(value) when Regexp, Module then @predicate === value else @predicate.call(value) end if @should_conform ret else ret ? value : :"Speculation/invalid" end end
# File lib/speculation/spec/predicate_spec.rb, line 44 def explain(path, via, inn, value) if S.invalid?(S.dt(@predicate, value)) [{ :path => path, :val => value, :via => via, :in => inn, :pred => [@predicate, [value]] }] end end
# File lib/speculation/spec/predicate_spec.rb, line 54 def gen(_, _, _) if @gen @gen.call else Gen.gen_for_pred(@predicate) end end
# File lib/speculation/spec/predicate_spec.rb, line 62 def inspect "#{self.class}(#{@name || @predicate.inspect})" end
# File lib/speculation/spec/predicate_spec.rb, line 34 def unform(value) return value unless @should_conform if @unconformer @unconformer.call(value) else raise "no unformer for conformer" end end
# File lib/speculation/spec/predicate_spec.rb, line 50 def with_gen(gen) self.class.new(@predicate, @should_conform, gen, @unconformer) end