Class: Wamupd::AvahiService
- Inherits:
-
Object
- Object
- Wamupd::AvahiService
- Defined in:
- lib/wamupd/avahi_service.rb
Overview
A single <service> entry from a service record. A given service file (representated by an AvahiServiceFile) may contain many AvahiServices.
Instance Attribute Summary collapse
-
#domainname ⇒ Object
readonly
Returns the value of attribute domainname.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#subtype ⇒ Object
readonly
Returns the value of attribute subtype.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#identifier ⇒ Object
A key that can be used to identify this service.
-
#initialize(name, param) ⇒ AvahiService
constructor
Initialize.
-
#subtype_display ⇒ Object
Get the subtype as Apple displays it.
-
#target ⇒ Object
The target of this service.
-
#to_s ⇒ Object
String coercer.
-
#txt ⇒ Object
TXT record.
-
#type_in_zone ⇒ Object
The full type in this zone.
-
#type_in_zone_with_name ⇒ Object
The type and name in this zone.
Constructor Details
#initialize(name, param) ⇒ AvahiService
Initialize
Argument: Either an XML node or a hash with some useful subset of the parameters :type, :subtype, :hostname, :port, :txt, and :domainname
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/wamupd/avahi_service.rb', line 91 def initialize(name, param) @name = name mapping = {:type=>:@type, :subtype=>:@subtype, :hostname=>:@hostname, :port=>:@port, :txt=>:@txt, :domainname=>:@domainname } mapping.each {|k,v| if (param.has_key?(k)) self.instance_variable_set(v, param[k]) end } end |
Instance Attribute Details
#domainname ⇒ Object (readonly)
Returns the value of attribute domainname.
27 28 29 |
# File 'lib/wamupd/avahi_service.rb', line 27 def domainname @domainname end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
25 26 27 |
# File 'lib/wamupd/avahi_service.rb', line 25 def hostname @hostname end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/wamupd/avahi_service.rb', line 28 def name @name end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
26 27 28 |
# File 'lib/wamupd/avahi_service.rb', line 26 def port @port end |
#subtype ⇒ Object (readonly)
Returns the value of attribute subtype.
24 25 26 |
# File 'lib/wamupd/avahi_service.rb', line 24 def subtype @subtype end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
23 24 25 |
# File 'lib/wamupd/avahi_service.rb', line 23 def type @type end |
Instance Method Details
#identifier ⇒ Object
A key that can be used to identify this service. Is the subtype-type followed by a - followed by the port
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/wamupd/avahi_service.rb', line 49 def identifier retval = "" if (@subtype) retval += @subtype retval += "." end if (@type) retval += @type retval += "-" end retval += @port.to_s return retval end |
#subtype_display ⇒ Object
Get the subtype as Apple displays it
31 32 33 |
# File 'lib/wamupd/avahi_service.rb', line 31 def subtype_display "#{@type},#{@subtype}" end |
#target ⇒ Object
The target of this service
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/wamupd/avahi_service.rb', line 64 def target t = "" sa = MainSettings.instance if (@hostname.nil?) t += sa.hostname else t += @hostname end t += "." if (@domainname.nil?) t += sa.zone else t += @domainname end end |
#to_s ⇒ Object
String coercer
108 109 110 |
# File 'lib/wamupd/avahi_service.rb', line 108 def to_s "<AvahiService name='#{@name}' type=#{@type} txt=#{self.txt}>" end |
#txt ⇒ Object
TXT record
81 82 83 |
# File 'lib/wamupd/avahi_service.rb', line 81 def txt return (@txt.nil? || @txt == "") ? false : @txt end |
#type_in_zone ⇒ Object
The full type in this zone. Goes in the PTR
42 43 44 45 |
# File 'lib/wamupd/avahi_service.rb', line 42 def type_in_zone sa = MainSettings.instance return @type + "." + sa.zone end |
#type_in_zone_with_name ⇒ Object
The type and name in this zone. Name of the SRV and TXT records
36 37 38 39 |
# File 'lib/wamupd/avahi_service.rb', line 36 def type_in_zone_with_name sa = MainSettings.instance return sa.hostname + "." + @type + "."+ sa.zone end |