Class: EnomRuby::Domain

Inherits:
Object
  • Object
show all
Defined in:
lib/enom-ruby/domain.rb

Constant Summary collapse

DEFAULT_TLDS =
['com']

Class Method Summary collapse

Instance Method Summary collapse

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/enom-ruby/domain.rb', line 21

def available?
  @availability_text == 'Domain available'
end

#unavailable?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/enom-ruby/domain.rb', line 25

def unavailable?
  not available?
end

#urlObject



29
30
31
# File 'lib/enom-ruby/domain.rb', line 29

def url
  @domain
end