Class: Adhoc::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/adhoc/service.rb

Overview

Adhoc service.

Constant Summary

@@subclasses = :nodoc:.
[]

Instance Attribute Summary

Class Method Summary

Instance Method Summary

Constructor Details

- (Service) initialize(reply = nil)

A new instance of Service



38
39
40
# File 'lib/adhoc/service.rb', line 38

def initialize(reply = nil)
  @reply = reply
end

Instance Attribute Details

- (Object) reply

Returns the value of attribute reply



36
37
38
# File 'lib/adhoc/service.rb', line 36

def reply
  @reply
end

Class Method Details

+ (Object) each(&block) {|klass| ... }

Enumerates known service types.

Yields:

  • (klass)

Yield Parameters:

  • (Class)


9
10
11
# File 'lib/adhoc/service.rb', line 9

def self.each(&block)
  @@subclasses.each { |klass| block.call(klass) }
end

+ (Class) for(type)

Returns:

  • (Class)


15
16
17
18
19
20
21
22
# File 'lib/adhoc/service.rb', line 15

def self.for(type)
  case type
    when Symbol  then const_get(type.to_s.upcase)
    when String  then const_get(type.upcase)
    when Service then type.class
    when Class   then type
  end
end

+ (Symbol) to_sym

Returns:

  • (Symbol)


32
33
34
# File 'lib/adhoc/service.rb', line 32

def self.to_sym
  name.to_s.split(':').last.downcase.to_sym
end

+ (String) type

Returns:

  • (String)


26
27
28
# File 'lib/adhoc/service.rb', line 26

def self.type
  const_get(:DNSSD_TYPE)
end

Instance Method Details

- (Object) name



42
# File 'lib/adhoc/service.rb', line 42

def name()   reply.name end

- (Object) to_s



48
49
50
51
# File 'lib/adhoc/service.rb', line 48

def to_s
  scheme = self.class.name.split(':').last.downcase
  "#{scheme}://#{reply.target}:#{reply.port}"
end

- (Object) to_uri



46
# File 'lib/adhoc/service.rb', line 46

def to_uri() URI.parse(to_s) end

- (Object) to_url



44
# File 'lib/adhoc/service.rb', line 44

def to_url() to_uri end