Class: DomainFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/uncoil/domain_finder.rb

Instance Method Summary collapse

Instance Method Details

#domain_for(short_url) ⇒ Object



4
5
6
7
# File 'lib/uncoil/domain_finder.rb', line 4

def domain_for(short_url)
  #TODO: new object here?
  match_host_to_provider(host_for(short_url))
end

#host_for(url) ⇒ Object



9
10
11
# File 'lib/uncoil/domain_finder.rb', line 9

def host_for(url)
  URI.parse(url).host
end

#match_host_to_provider(host) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/uncoil/domain_finder.rb', line 13

def match_host_to_provider(host)
  case
  when bitly_domains.include?(host)
    :bitly
  when isgd_domains.include?(host)
    :isgd
  else
    host
  end
end