Class: MiniDisc::Registry::Service
- Inherits:
-
Object
- Object
- MiniDisc::Registry::Service
- Defined in:
- lib/minidisc/registry.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(service_type, port, options = {}) ⇒ Service
constructor
A new instance of Service.
-
#register(options = {}) ⇒ Boolean
Register this service.
- #registered? ⇒ Boolean
Constructor Details
#initialize(service_type, port, options = {}) ⇒ Service
Returns a new instance of Service.
29 30 31 32 33 |
# File 'lib/minidisc/registry.rb', line 29 def initialize(service_type, port, = {}) @id = .fetch(:id, object_id.to_s) @port = port @service_type = ServiceType.sym_to_dnnsd_string(service_type, ) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
25 26 27 |
# File 'lib/minidisc/registry.rb', line 25 def id @id end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
25 26 27 |
# File 'lib/minidisc/registry.rb', line 25 def logger @logger end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
25 26 27 |
# File 'lib/minidisc/registry.rb', line 25 def port @port end |
Instance Method Details
#register(options = {}) ⇒ Boolean
Register this service
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/minidisc/registry.rb', line 41 def register( = {}) DNSSD.register(@id, @service_type, nil, @port) do properties = "id=#{@id} port=#{@port} service_type=#{@service_type}" unless [:logger].nil? [:logger].info("MiniDisc::Registry::Service#register: #{properties}") end end @registered = true rescue Errno::EBADF @registered = false end |
#registered? ⇒ Boolean
35 36 37 |
# File 'lib/minidisc/registry.rb', line 35 def registered? @registered end |