class Contracts::Builtin::Not

Takes a variable number of contracts. The contract passes if all of those contracts fail for the given argument. Example: Not[nil]

Public Class Methods

new(*vals) click to toggle source
# File lib/contracts/builtin_contracts.rb, line 254
def initialize(*vals)
  @vals = vals
end

Public Instance Methods

to_s() click to toggle source
# File lib/contracts/builtin_contracts.rb, line 265
def to_s
  "a value that is none of #{@vals.inspect}"
end
valid?(val) click to toggle source
# File lib/contracts/builtin_contracts.rb, line 258
def valid?(val)
  @vals.all? do |contract|
    res, _ = Contract.valid?(val, contract)
    !res
  end
end