Class: Validators::TLD
- Inherits:
-
Object
- Object
- Validators::TLD
- Defined in:
- lib/validators/tld.rb
Constant Summary collapse
- FILE_PATH =
File.("../../data/tld.json", __dir__)
Class Method Summary collapse
Class Method Details
.all ⇒ Object
7 8 9 |
# File 'lib/validators/tld.rb', line 7 def self.all @all ||= JSON.parse(File.read(FILE_PATH)) end |
.host_with_valid_tld?(host) ⇒ Boolean
11 12 13 14 15 |
# File 'lib/validators/tld.rb', line 11 def self.host_with_valid_tld?(host) return false if host.split(".").size == 1 valid? host[/\.([^.]+)$/, 1].to_s.downcase end |
.valid?(tld) ⇒ Boolean
17 18 19 |
# File 'lib/validators/tld.rb', line 17 def self.valid?(tld) all.include?(tld) end |