Class: RadioDNS::Service
- Inherits:
-
Object
- Object
- RadioDNS::Service
- Defined in:
- lib/radiodns.rb
Instance Attribute Summary collapse
-
#cname ⇒ Object
Returns the value of attribute cname.
Instance Method Summary collapse
- #application(service) ⇒ Object
- #applications ⇒ Object
-
#initialize(cname) ⇒ Service
constructor
A new instance of Service.
- #radioepg ⇒ Object
- #radiotag ⇒ Object
- #radiovis ⇒ Object
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
#cname ⇒ Object
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 |
#applications ⇒ Object
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 |
#radioepg ⇒ Object
14 15 16 |
# File 'lib/radiodns.rb', line 14 def radioepg application(:radioepg) end |
#radiotag ⇒ Object
18 19 20 |
# File 'lib/radiodns.rb', line 18 def radiotag application(:radiotag) end |
#radiovis ⇒ Object
10 11 12 |
# File 'lib/radiodns.rb', line 10 def radiovis application(:radiovis) end |