Class: Easyjour::Search
- Inherits:
-
Object
- Object
- Easyjour::Search
- Defined in:
- lib/easyjour.rb
Instance Method Summary collapse
-
#initialize(service, protocol = :tcp) ⇒ Search
constructor
A new instance of Search.
-
#results ⇒ Object
Returns the current the results.
-
#stop ⇒ Object
Stop the search.
Constructor Details
#initialize(service, protocol = :tcp) ⇒ Search
Returns a new instance of Search.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/easyjour.rb', line 78 def initialize(service, protocol = :tcp) @results = [] @results_mutex = Mutex.new @query = DNSSD.browse(Easyjour.type_from_parts(service, protocol)) do |reply| DNSSD.resolve(reply.name, reply.type, reply.domain) do |reply| yield(reply) if block_given? @results_mutex.synchronize do @results << reply end end end end |
Instance Method Details
#results ⇒ Object
Returns the current the results.
94 95 96 97 98 |
# File 'lib/easyjour.rb', line 94 def results @results_mutex.synchronize do @results end end |
#stop ⇒ Object
Stop the search.
101 102 103 |
# File 'lib/easyjour.rb', line 101 def stop @query.stop end |