模块:Mongoid::Matcher::Bits Private
- 包含在:
- BitsAllClear, BitsAllSet, BitsAnyClear, BitsAnySet
- 定义于:
- lib/mongoid/matcher/bits.rb
Overview
该模块是私有 API 的一部分。 您应尽可能避免使用此模块,因为它将来可能会被删除或更改。
按位表达式匹配器中包含的 Mixin 模块。
类方法摘要折叠
- 
  
    
      。 Operator_name ⇒ string 
    
    
  
  
  
  
  
  
  
  private
  
    返回表达式操作符的名称。 
实例方法摘要折叠
- 
  
    
      # matches? (exists、value、condition)→ true | false 
    
    
  
  
  
  
  
  
  
  private
  
    返回值是否满足按位表达式。 
类方法详细信息
。 Operator_name ⇒ string
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回表达式操作符的名称。
| 55 56 57 | # File 'lib/mongoid/matcher/bits.rb', line 55 module_function def Operator_name 名称.子(/ .*:: /, ' ').子(/ \A(.) /) { |l| l.Downcase } end | 
实例方法详细信息
# matches? (exists、value、condition)→ true | false
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回值是否满足按位表达式。
| 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # File 'lib/mongoid/matcher/bits.rb', line 20 def 匹配?(存在, 值, 条件) 案例 值 when BSON::二进制文件 值 = 值.数据.拆分(' ').map { |n| '%02x' % n.ord }.连接 (JOIN).to_i(16) end 案例 条件 when 阵列 array_matches?(值, 条件) when BSON::二进制文件 int_cond = 条件.数据.拆分(' ').map { |n| '%02x' % n.ord }.连接 (JOIN).to_i(16) int_matches?(值, int_cond) when 整型 if 条件 < 0 提高 Errors::InvalidQuery, " $ #{ operator_name } 参数 的值无效 :不允许使用负整数: #{ condition } " end int_matches?(值, 条件) when Float if (int_cond = 条件.to_i).to_f == 条件 if int_cond < 0 提高 Errors::InvalidQuery, " $ #{ operator_name }参数的值无效:不允许使用负数: #{ condition } " end int_matches?(值, int_cond) else 提高 Errors::InvalidQuery, " $ #{ operator_name} 参数的 类型无效 :无法表示为整数: #{ condition} " end else 提高 Errors::InvalidQuery, " $ #{ operator_name } 参数 的类型无效 : #{ condition } " end end |