Class: BitterDomain::DomainChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/bitter_domain/domain_checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domains) ⇒ DomainChecker

Returns a new instance of DomainChecker.



8
9
10
11
12
13
14
15
# File 'lib/bitter_domain/domain_checker.rb', line 8

def initialize(domains)
  @domains = domains
  @available = []
  @errors = []
  @tested = []
  @whois = Whois::Client.new
  @error_msgs = []
end

Instance Attribute Details

#availableObject (readonly)

Returns the value of attribute available.



7
8
9
# File 'lib/bitter_domain/domain_checker.rb', line 7

def available
  @available
end

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/bitter_domain/domain_checker.rb', line 7

def errors
  @errors
end

#testedObject (readonly)

Returns the value of attribute tested.



7
8
9
# File 'lib/bitter_domain/domain_checker.rb', line 7

def tested
  @tested
end

Instance Method Details



41
42
43
44
# File 'lib/bitter_domain/domain_checker.rb', line 41

def print_available
  @available.each { |domain| puts domain }
  puts "No available domains" if @available.empty?
end


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bitter_domain/domain_checker.rb', line 17

def print_verbose
  puts "\n\nHere are all the tested domains\n".blue
  @tested.each { |domain| puts domain }

  if @errors.any?
    puts "\n\nHere are all of the domains that errored out\n".red
    @errors.each { |domain| puts domain }
  end

  if @error_msgs.any?
    puts "\n\nHere are the error messages\n".red
    @error_msgs.each { |msg| puts msg }
  end

  rejected = @tested - @available
  if rejected.any?
    puts "\n\nHere are the rejected domains".yellow
    rejected.each { |dom| puts dom }
  end

  puts "\n\nHere are the available domains\n".green
  print_available
end

#retryObject



50
51
52
53
54
# File 'lib/bitter_domain/domain_checker.rb', line 50

def retry
  copies = @errors.dup
  @errors = []
  query_domains(copies)
end

#test_domainsObject



46
47
48
# File 'lib/bitter_domain/domain_checker.rb', line 46

def test_domains
  query_domains(@domains)
end