Class: Tradfri::Service
- Inherits:
-
Struct
- Object
- Struct
- Tradfri::Service
- Defined in:
- lib/tradfri/service.rb
Constant Summary collapse
- SERVICE_TYPE =
'_coap'
- TRANSPORT_PROTOCOL =
'_udp'
- INTERNET_PROTOCOL =
DNSSD::Service::IPv4
- REGISTRATION_TYPE =
[SERVICE_TYPE, TRANSPORT_PROTOCOL].join('.')
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#name ⇒ Object
Returns the value of attribute name.
-
#port ⇒ Object
Returns the value of attribute port.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host
4 5 6 |
# File 'lib/tradfri/service.rb', line 4 def host @host end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/tradfri/service.rb', line 4 def name @name end |
#port ⇒ Object
Returns the value of attribute port
4 5 6 |
# File 'lib/tradfri/service.rb', line 4 def port @port end |
Class Method Details
.discover ⇒ Object
15 16 17 18 19 20 |
# File 'lib/tradfri/service.rb', line 15 def self.discover browse(REGISTRATION_TYPE).map do |reply| host, port = resolve(reply, INTERNET_PROTOCOL) Service.new(reply.name, host, port) end end |
Instance Method Details
#mac_address ⇒ Object
10 11 12 13 |
# File 'lib/tradfri/service.rb', line 10 def mac_address name.slice %r{(?:\h{2}-){5}\h{2}} || raise("couldn’t find MAC address in “#{name}”") end |