class Speculation::NilableSpec
@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.
Public Class Methods
new(pred, gen = nil)
click to toggle source
# File lib/speculation/spec/nilable_spec.rb, line 13 def initialize(pred, gen = nil) @pred = pred @gen = gen @delayed_spec = Concurrent::Delay.new { S.send(:specize, pred) } end
Public Instance Methods
conform(value)
click to toggle source
# File lib/speculation/spec/nilable_spec.rb, line 19 def conform(value) value.nil? ? value : @delayed_spec.value!.conform(value) end
explain(path, via, inn, value)
click to toggle source
# File lib/speculation/spec/nilable_spec.rb, line 27 def explain(path, via, inn, value) return if S.pvalid?(@delayed_spec.value!, value) || value.nil? Utils.conj( S.explain1(@pred, Utils.conj(path, :pred), via, inn, value), :path => Utils.conj(path, :nil), :pred => [NilClass, [value]], :val => value, :via => via, :in => inn ) end
gen(overrides, path, rmap)
click to toggle source
# File lib/speculation/spec/nilable_spec.rb, line 40 def gen(overrides, path, rmap) return @gen.call if @gen ->(rantly) do rantly.freq([1, Gen.delay { Utils.constantly(nil) }], [9, Gen.delay { S.gensub(@pred, overrides, Utils.conj(path, :pred), rmap) }]) end end
unform(value)
click to toggle source
# File lib/speculation/spec/nilable_spec.rb, line 23 def unform(value) value.nil? ? nil : @delayed_spec.value!.unform(value) end
with_gen(gen)
click to toggle source
# File lib/speculation/spec/nilable_spec.rb, line 36 def with_gen(gen) self.class.new(@pred, gen) end