Sha256: 4a579b18674b4fb8aa1985b933a6025bf9ed7ba26d2589d4ca9c22ec09ca4405
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
# encoding: utf-8 module Selector # The inversion of another condition # class Not < Condition # @private def self.new(source) return NOTHING if source.equal? ANYTHING return ANYTHING if source.equal? NOTHING super end # Checks if the value doesn't satisfy inverted condition # # @example # condition = Selector.new(only: [:foo]) # inversion[:foo] # => true # inversion[:bar] # => false # # inversion = Not.new(condition) # inversion[:foo] # => false # inversion[:bar] # => true # # @param (see Selector::Condition#[]) # # @return (see Selector::Condition#[]) # def [](value) !attribute[value] end # Returns the inverted condition (avoids double negation) # # @example # condition = Selector.new(only: [:foo]) # inversion = Not.new(condition) # !inversion == condition # => true # # @return (see Selector::Condition#!) # def ! attribute end end # class Not end # module Selector
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
selector-0.0.3 | lib/selector/not.rb |
selector-0.0.2 | lib/selector/not.rb |
selector-0.0.1 | lib/selector/not.rb |