Support for the Ruby 2.4 series has ended. See here for reference.

In Files

  • net/imap.rb

Net::IMAP::NumValidator

Common validators of number and nz_number types

Public Class Methods

ensure_number(num) click to toggle source

Ensure argument is 'number' or raise DataFormatError

 
               # File net/imap.rb, line 1634
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) click to toggle source

Ensure argument is 'nz_number' or raise DataFormatError

 
               # File net/imap.rb, line 1642
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) click to toggle source

Check is passed argument valid 'number' in RFC 3501 terminology

 
               # File net/imap.rb, line 1616
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) click to toggle source

Check is passed argument valid 'nz_number' in RFC 3501 terminology

 
               # File net/imap.rb, line 1625
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