Class: Validate::AST::Rules::Negative
Instance Method Summary
collapse
included
Methods included from Combinator
#respond_to_missing?
Methods inherited from Constraint
#==, create_class, inherited, #method_missing, #respond_to_missing?, #to_s
Constructor Details
#initialize(constraints) ⇒ Negative
Returns a new instance of Negative.
347
348
349
|
# File 'lib/validate/ast.rb', line 347
def initialize(constraints)
@constraints = constraints.freeze
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Validate::Constraint
Instance Method Details
#inspect ⇒ Object
373
374
375
376
377
|
# File 'lib/validate/ast.rb', line 373
def inspect
return "!#{@constraints.first.inspect}" if @constraints.one?
"!(#{@constraints.map(&:inspect).join(' & ')})"
end
|
#message ⇒ Object
363
364
365
366
367
368
369
370
371
|
# File 'lib/validate/ast.rb', line 363
def message
return "not [#{constraint_message(0)}]" if @constraints.one?
'neither ' + @constraints
.size
.times
.map { |i| "[#{constraint_message(i)}]" }
.join(', nor ')
end
|
#name ⇒ Object
359
360
361
|
# File 'lib/validate/ast.rb', line 359
def name
'neither_' + @constraints.map(&:name).sort.join('_nor_')
end
|
#valid?(value, _ = Constraints::ValidationContext.none) ⇒ Boolean