在线文档教程
Ruby 2.4

Net::IMAP::NumValidator

Net :: IMAP :: NumValidator模块

数字和nz_number类型的通用验证器

公共类方法

ensure_number(num) Show source

确保参数是'number'或引发DataFormatError

# File lib/net/imap.rb, line 1633 def ensure_number(num) return if valid_number?(num) msg = "number must be unsigned 32-bit integer: #{num}" raise DataFormatError, msg end

ensure_nz_number(num) Show source

确保参数是'nz_number'或引发DataFormatError

# File lib/net/imap.rb, line 1641 def ensure_nz_number(num) return if valid_nz_number?(num) msg = "nz_number must be non-zero unsigned 32-bit integer: #{num}" raise DataFormatError, msg end

valid_number?(num) Show source

在RFC 3501术语中,检查通过参数有效的“number”

# File lib/net/imap.rb, line 1615 def valid_number?(num) # [RFC 3501] # number = 1*DIGIT # ; Unsigned 32-bit integer # ; (0 <= n < 4,294,967,296) num >= 0 && num < 4294967296 end

valid_nz_number?(num) Show source

在RFC 3501术语中,检查传递参数有效'nz_number'

# File lib/net/imap.rb, line 1624 def valid_nz_number?(num) # [RFC 3501] # nz-number = digit-nz *DIGIT # ; Non-zero unsigned 32-bit integer # ; (0 < n < 4,294,967,296) num != 0 && valid_number?(num) end