Class: RadioDNS::Resolver

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

Class Method Summary collapse

Class Method Details

.construct_fqdn(params) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/radiodns.rb', line 61

def self.construct_fqdn(params)
  bearer = params[:bearer]
  case bearer
    when "fm" then construct_fqdn_for_fm(params)
    when "dab" then construct_fqdn_for_dab(params)
    when "drm" then construct_fqdn_for_drm_or_amss(params)
    when "amss" then construct_fqdn_for_drm_or_amss(params)
    when "hd" then construct_fqdn_for_hd(params)
  end
end

.resolve(fqdn) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/radiodns.rb', line 51

def self.resolve(fqdn)
  if fqdn.is_a? Hash
    fqdn = construct_fqdn(fqdn)
  end

  resolver = Resolv::DNS.new
  cname = resolver.getresource(fqdn, Resolv::DNS::Resource::IN::CNAME)
  Service.new(cname.name.to_s)
end