Class: BitterDomain::DomainMapper

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain) ⇒ DomainMapper

Returns a new instance of DomainMapper.



9
10
11
12
13
# File 'lib/bitter_domain/domain_mapper.rb', line 9

def initialize(domain)
  @domain = parse_domain(domain)
  @checker = nil
  @shifted_domains = []
end

Instance Attribute Details

#domainObject

Returns the value of attribute domain.



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

def domain
  @domain
end

#shifted_domainsObject (readonly)

Returns the value of attribute shifted_domains.



6
7
8
# File 'lib/bitter_domain/domain_mapper.rb', line 6

def shifted_domains
  @shifted_domains
end

Instance Method Details

#check_domains(attempt_retry = false) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/bitter_domain/domain_mapper.rb', line 32

def check_domains(attempt_retry=false)
  self.checker = BitterDomain::DomainChecker.new(@shifted_domains)
  self.checker.test_domains
  
  self.checker.retry if attempt_retry

  self.checker.available
end

#gen_shiftsObject



15
16
17
18
19
20
21
# File 'lib/bitter_domain/domain_mapper.rb', line 15

def gen_shifts
  host = @domain.sld
  shifter = BitterDomain::BitShifter.new(host)
  self.checker = nil
  @shifted_domains = shifter.get_shifted_domains
    .map { |dom| "#{dom}.#{@domain.tld}" }
end

#get_availableObject



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

def get_available
  self.checker.available
end

#get_errorsObject



45
46
47
# File 'lib/bitter_domain/domain_mapper.rb', line 45

def get_errors
  self.checker.errors
end

#get_testedObject



49
50
51
# File 'lib/bitter_domain/domain_mapper.rb', line 49

def get_tested
  self.checker.tested
end


61
62
63
64
# File 'lib/bitter_domain/domain_mapper.rb', line 61

def print_available
  puts "Here are the available shifted domains"
  self.checker.print_available
end


23
24
25
# File 'lib/bitter_domain/domain_mapper.rb', line 23

def print_shifts
  self.shifted_domains.each { |shift| $stdout.puts "#{shift}" }
end


57
58
59
# File 'lib/bitter_domain/domain_mapper.rb', line 57

def print_verbose
  self.checker.print_verbose
end

#query_shiftsObject



66
67
68
69
70
71
# File 'lib/bitter_domain/domain_mapper.rb', line 66

def query_shifts
  gen_shifts
  check_domains

  get_available
end

#retryObject



53
54
55
# File 'lib/bitter_domain/domain_mapper.rb', line 53

def retry
  self.checker.retry
end