Module: FakeRedis::BitopCommand

Defined in:
lib/fakeredis/bitop_command.rb

Constant Summary collapse

BIT_OPERATORS =
{
  'or'  => :|,
  'and' => :&,
  'xor' => :'^',
  'not' => :~,
}

Instance Method Summary collapse

Instance Method Details

#bitop(operation, destkey, *keys) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/fakeredis/bitop_command.rb', line 10

def bitop(operation, destkey, *keys)
  if result = apply(operator(operation), keys)
    set(destkey, result)
    result.length
  else
    0
  end
rescue ArgumentError => _
  raise_argument_error('bitop')
end