123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Matcher::BitsAllClear Private

Do not use. This module is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Bits
Defined in: lib/mongoid/matcher/bits_all_clear.rb

Overview

In-memory matcher for $bitsAllClear expression.

Instance Method Summary

Bits - Included

#matches?

Returns whether a value satisfies a bitwise expression.

Instance Method Details

#array_matches?(value, condition) ⇒ true | false

Returns whether a position list condition matches a value.

Parameters:

  • value (Object)

    The value to check.

  • condition (Array<Numeric>)

    The position list condition.

Returns:

  • (true | false)

    Whether the value matches.

[ GitHub ]

  
# File 'lib/mongoid/matcher/bits_all_clear.rb', line 22

def array_matches?(value, condition)
  condition.all? do |c|
    value & (1<<c) == 0
  end
end

#int_matches?(value, condition) ⇒ true | false

Returns whether a bitmask condition matches a value.

Parameters:

  • value (Object)

    The value to check.

  • condition (Numeric)

    The bitmask condition.

Returns:

  • (true | false)

    Whether the value matches.

[ GitHub ]

  
# File 'lib/mongoid/matcher/bits_all_clear.rb', line 36

def int_matches?(value, condition)
  value & condition == 0
end