Class: Yargi::NotPredicate

Inherits:
Predicate show all
Defined in:
lib/yargi/predicate.rb

Overview

Negates another predicate

Constant Summary

Constants inherited from Predicate

Predicate::ALL, Predicate::NONE

Instance Method Summary collapse

Methods inherited from Predicate

#&, #not, to_predicate, #|

Constructor Details

#initialize(negated) ⇒ NotPredicate

Creates a ‘not(negated)’ predicate



139
140
141
# File 'lib/yargi/predicate.rb', line 139

def initialize(negated)
  @negated = Predicate.to_predicate(negated)
end

Instance Method Details

#===(elm) ⇒ Object

Predicate implementation



144
145
146
# File 'lib/yargi/predicate.rb', line 144

def ===(elm)
  not(@negated === elm)
end

#inspectObject

Helps debugging predicates



149
150
151
# File 'lib/yargi/predicate.rb', line 149

def inspect
  "not(#{@negated})"
end