Class: Validators::TLD
- Inherits:
-
Object
- Object
- Validators::TLD
- Defined in:
- lib/validators/tld.rb
Class Method Summary collapse
Class Method Details
.all ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/validators/tld.rb', line 5 def self.all @all ||= begin require "email_data" EmailData.tlds rescue LoadError raise "email_data is not part of the bundle. Add it to Gemfile." end end |
.host_with_valid_tld?(host) ⇒ Boolean
15 16 17 18 19 20 21 |
# File 'lib/validators/tld.rb', line 15 def self.host_with_valid_tld?(host) host = host.to_s return false if host.split(".").size == 1 include?(host[/\.([^.]+)$/, 1].to_s.downcase) end |
.include?(tld) ⇒ Boolean
23 24 25 |
# File 'lib/validators/tld.rb', line 23 def self.include?(tld) all.include?(tld) end |