Module: Redis::Bitops::Queries::TreeBuildingHelpers
- Included in:
- BinaryOperator, UnaryOperator
- Defined in:
- lib/redis/bitops/queries/tree_building_helpers.rb
Overview
Helpers for expression tree building.
Add new logical operators here as/if they become supported by Redis’ BITOP command.
Instance Method Summary collapse
-
#&(rhs) ⇒ Object
Logical AND operator.
-
#^(rhs) ⇒ Object
Logical XOR operator.
-
#|(rhs) ⇒ Object
Logical OR operator.
-
#~ ⇒ Object
Logical NOT operator.
Instance Method Details
#&(rhs) ⇒ Object
Logical AND operator.
12 13 14 |
# File 'lib/redis/bitops/queries/tree_building_helpers.rb', line 12 def & (rhs) BinaryOperator.new(:and, self, rhs) end |
#^(rhs) ⇒ Object
Logical XOR operator.
24 25 26 |
# File 'lib/redis/bitops/queries/tree_building_helpers.rb', line 24 def ^ (rhs) BinaryOperator.new(:xor, self, rhs) end |
#|(rhs) ⇒ Object
Logical OR operator.
18 19 20 |
# File 'lib/redis/bitops/queries/tree_building_helpers.rb', line 18 def | (rhs) BinaryOperator.new(:or, self, rhs) end |
#~ ⇒ Object
Logical NOT operator.
IMPORTANT: It inverts bits padding with zeroes till the nearest byte boundary. It means that setting the left-most bit to 1 and inverting will result in 01111111 not 0.
Corresponding Redis commands:
SETBIT “a” 0 1 BITOP NOT “b” “a” BITCOUNT “b”
> (integer) 7
40 41 42 |
# File 'lib/redis/bitops/queries/tree_building_helpers.rb', line 40 def ~ UnaryOperator.new(:not, self) end |