Class: EnomRuby::Domain
- Inherits:
-
Object
- Object
- EnomRuby::Domain
- Defined in:
- lib/enom-ruby/domain.rb
Constant Summary collapse
- DEFAULT_TLDS =
['com']
Class Method Summary collapse
- .bulk_register(sld, tld_list = DEFAULT_TLDS) ⇒ Object
-
.check(sld, tld_list = DEFAULT_TLDS) ⇒ Object
Check a particular domain (sld) with an array of tlds (tld_list).
-
.tld_list ⇒ Object
Return an array of all the available TLDs to check against.
Instance Method Summary collapse
- #available? ⇒ Boolean
-
#initialize(domain, availability_text) ⇒ Domain
constructor
A new instance of Domain.
- #unavailable? ⇒ Boolean
- #url ⇒ Object
Constructor Details
#initialize(domain, availability_text) ⇒ Domain
Returns a new instance of Domain.
40 41 42 43 |
# File 'lib/enom-ruby/domain.rb', line 40 def initialize(domain, availability_text) @domain = domain @availability_text = availability_text end |
Class Method Details
.bulk_register(sld, tld_list = DEFAULT_TLDS) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/enom-ruby/domain.rb', line 24 def self.bulk_register(sld, tld_list = DEFAULT_TLDS) responses = [] tld_list.each_slice(4) do |group| query = {} group.each_with_index do |tld, idx| query["tld#{idx+1}"] = tld query["sld#{idx+1}"] = sld end query[:command] = 'AddBulkDomains' query[:producttype] = 'register' query[:listcount] = group.size responses << Client.request(query) end responses end |
.check(sld, tld_list = DEFAULT_TLDS) ⇒ Object
Check a particular domain (sld) with an array of tlds (tld_list)
9 10 11 12 13 14 15 |
# File 'lib/enom-ruby/domain.rb', line 9 def self.check(sld, tld_list = DEFAULT_TLDS) response = Client.request(command: 'Check', sld: sld, tldlist: Array(tld_list).take(15).join(',')) domains = Hash[*Array(response['Domain']).zip(Array(response['RRPText'])).flatten] [].tap do |results| domains.each_pair { |domain, text| results << new(domain, text) } end end |
.tld_list ⇒ Object
Return an array of all the available TLDs to check against
18 19 20 21 22 |
# File 'lib/enom-ruby/domain.rb', line 18 def self.tld_list response = Client.request(command: 'GetTLDList') tld_list = response['tldlist']['tld'].collect(&:values).flatten tld_list.compact.reject {|d| d.include?('--') || d.match(/\d+/) } end |
Instance Method Details
#available? ⇒ Boolean
45 46 47 |
# File 'lib/enom-ruby/domain.rb', line 45 def available? @availability_text == 'Domain available' end |
#unavailable? ⇒ Boolean
49 50 51 |
# File 'lib/enom-ruby/domain.rb', line 49 def unavailable? not available? end |
#url ⇒ Object
53 54 55 |
# File 'lib/enom-ruby/domain.rb', line 53 def url @domain end |