module PhoneNumberChecker

PhoneNumberChecker

Constants

VERSION

Public Instance Methods

bd_phone() click to toggle source
# File lib/phone_number_checker.rb, line 21
def bd_phone
  phone = nil
  length = self.length
  if length == 11 && bd_phone?
    phone = self
  elsif length == 14 && bd_phone?
    phone = slice(3, length)
  elsif length == 15 && bd_phone?
    phone = slice(4, length)
  end
  phone
end
bd_phone?() click to toggle source
# File lib/phone_number_checker.rb, line 17
def bd_phone?
  !!match(bd_phone_regex)
end
bd_phone_regex() click to toggle source
# File lib/phone_number_checker.rb, line 9
def bd_phone_regex
  /(^(\+88|0088)?(01)[3456789](\d){8})$/
end
bd_phone_with_country_code() click to toggle source
# File lib/phone_number_checker.rb, line 34
def bd_phone_with_country_code
  phone = nil
  length = self.length
  if length == 11 && bd_phone?
    phone = "+88#{self}"
  elsif length == 14 && bd_phone?
    phone = "+88#{slice(3, length)}"
  elsif length == 15 && bd_phone?
    phone = "+88#{slice(4, length)}"
  end
  phone
end
white_space?() click to toggle source
# File lib/phone_number_checker.rb, line 13
def white_space?
  !!match(/\s/)
end