Class: Validators::TLD

Inherits:
Object
  • Object
show all
Defined in:
lib/validators/tld.rb

Class Method Summary collapse

Class Method Details

.allObject



5
6
7
8
9
10
11
# File 'lib/validators/tld.rb', line 5

def self.all
  @all ||=
    begin
      Validators.require_dependency! "email_data"
      EmailData.tlds
    end
end

.host_with_valid_tld?(host) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
# File 'lib/validators/tld.rb', line 13

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/validators/tld.rb', line 21

def self.include?(tld)
  all.include?(tld)
end