class Selector::Condition
Describe an immutable condition for selecting values
Attributes
@!attribute [r] attributes
@return [Array] The array of initialized attributes
Public Class Methods
@private
# File lib/selector/condition.rb, line 26 def initialize(*attributes) @attributes = attributes IceNine.deep_freeze(self) end
Public Instance Methods
Inverts the condition
@return [Selector::Condition]
# File lib/selector/condition.rb, line 60 def ! Not.new(self) end
Composes (by AND) the condition to the other condition
@param [Selector::Condition] other
@return [Selector::Condition]
# File lib/selector/condition.rb, line 70 def &(other) And.new(self, other) end
Composes (by AND) the condition to inversion of the other condition
This is the same as ‘&(!other)`
@param [Selector::Condition] other
@return [Selector::Condition]
# File lib/selector/condition.rb, line 82 def -(other) And.new(self, !other) end
Compares the condition to the other object by type and attributes
@param [Object] other
@return [Boolean]
# File lib/selector/condition.rb, line 37 def ==(other) other.instance_of?(self.class) && attributes.eql?(other.attributes) end
@!method [](value) Checks if the value satisfies the condtion
@param [Object] value
@return [Boolean]
@abstract @raise [NotImplementedError] by default
# File lib/selector/condition.rb, line 52 def [](_value) fail NotImplementedError.new "#{self.class}#[] not implemented" end
The first attribute
@return [Object]
# File lib/selector/condition.rb, line 21 def attribute attributes.first end
Composes (by OR) the condition to the other condition
This is the same as ‘!((!self)&(!other))`
@param [Selector::Condition] other
@return [Selector::Condition]
# File lib/selector/condition.rb, line 94 def |(other) Or.new(self, other) end