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
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.
16 17 18 19 |
# File 'lib/enom-ruby/domain.rb', line 16 def initialize(domain, availability_text) @domain = domain @availability_text = availability_text end |
Class Method Details
.check(sld, tld_list = DEFAULT_TLDS) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/enom-ruby/domain.rb', line 8 def self.check(sld, tld_list = DEFAULT_TLDS) response = Client.request(command: 'Check', sld: sld, tldlist: tld_list.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 |
Instance Method Details
#available? ⇒ Boolean
21 22 23 |
# File 'lib/enom-ruby/domain.rb', line 21 def available? @availability_text == 'Domain available' end |
#unavailable? ⇒ Boolean
25 26 27 |
# File 'lib/enom-ruby/domain.rb', line 25 def unavailable? not available? end |
#url ⇒ Object
29 30 31 |
# File 'lib/enom-ruby/domain.rb', line 29 def url @domain end |