Class: RadioDNS::Service

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cname) ⇒ Service

Returns a new instance of Service.



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

def initialize(cname)
  @cname = cname
end

Instance Attribute Details

#cnameObject

Returns the value of attribute cname.



5
6
7
# File 'lib/radiodns.rb', line 5

def cname
  @cname
end

Instance Method Details

#application(service) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/radiodns.rb', line 31

def application(service)
  resolver = Resolv::DNS.new

  prefix = "_#{service.to_s}._tcp."
  host = prefix + cname
  resource = resolver.getresource(host, Resolv::DNS::Resource::IN::SRV)
  Application.new :host => resource.target.to_s, :port => resource.port, :type => service
end

#applicationsObject



22
23
24
25
26
27
28
29
# File 'lib/radiodns.rb', line 22

def applications
  applications = []
  [:radiotag, :radioepg, :radiovis].each do |method_name|
    application = self.send(method_name)
    applications << application if application
  end
  applications
end

#radioepgObject



14
15
16
# File 'lib/radiodns.rb', line 14

def radioepg
  application(:radioepg)
end

#radiotagObject



18
19
20
# File 'lib/radiodns.rb', line 18

def radiotag
  application(:radiotag)
end

#radiovisObject



10
11
12
# File 'lib/radiodns.rb', line 10

def radiovis
  application(:radiovis)
end