Class: Yast::SlpServiceClass::Service
- Inherits:
-
Object
- Object
- Yast::SlpServiceClass::Service
- Defined in:
- ../../src/modules/SlpService.rb
Instance Attribute Summary (collapse)
-
- (Object) attributes
readonly
Returns the value of attribute attributes.
-
- (Object) host
readonly
Returns the value of attribute host.
-
- (Object) ip
readonly
Returns the value of attribute ip.
-
- (Object) lifetime
readonly
Returns the value of attribute lifetime.
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) params
readonly
Returns the value of attribute params.
-
- (Object) port
readonly
Returns the value of attribute port.
-
- (Object) protocol
readonly
Returns the value of attribute protocol.
-
- (Object) slp_type
readonly
Returns the value of attribute slp_type.
-
- (Object) slp_url
readonly
Returns the value of attribute slp_url.
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (Service) initialize(params)
constructor
A new instance of Service.
- - (Boolean) verified?
Constructor Details
- (Service) initialize(params)
Returns a new instance of Service
128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File '../../src/modules/SlpService.rb', line 128 def initialize(params) @name = params.delete(:name) slp_data = params.delete(:data) @ip = slp_data['ip'] @port = slp_data['pcPort'] @slp_type = slp_data['pcSrvType'] @slp_url = slp_data['srvurl'] @protocol = slp_type.split(DELIMITER).last @host = DnsCache.resolve(ip) @lifetime = slp_data['lifetime'] @attributes = OpenStruct.new(SLP.GetUnicastAttrMap(slp_url, ip)) @params = params end |
Instance Attribute Details
- (Object) attributes (readonly)
Returns the value of attribute attributes
126 127 128 |
# File '../../src/modules/SlpService.rb', line 126 def attributes @attributes end |
- (Object) host (readonly)
Returns the value of attribute host
125 126 127 |
# File '../../src/modules/SlpService.rb', line 125 def host @host end |
- (Object) ip (readonly)
Returns the value of attribute ip
125 126 127 |
# File '../../src/modules/SlpService.rb', line 125 def ip @ip end |
- (Object) lifetime (readonly)
Returns the value of attribute lifetime
126 127 128 |
# File '../../src/modules/SlpService.rb', line 126 def lifetime @lifetime end |
- (Object) name (readonly)
Returns the value of attribute name
125 126 127 |
# File '../../src/modules/SlpService.rb', line 125 def name @name end |
- (Object) params (readonly)
Returns the value of attribute params
125 126 127 |
# File '../../src/modules/SlpService.rb', line 125 def params @params end |
- (Object) port (readonly)
Returns the value of attribute port
125 126 127 |
# File '../../src/modules/SlpService.rb', line 125 def port @port end |
- (Object) protocol (readonly)
Returns the value of attribute protocol
125 126 127 |
# File '../../src/modules/SlpService.rb', line 125 def protocol @protocol end |
- (Object) slp_type (readonly)
Returns the value of attribute slp_type
126 127 128 |
# File '../../src/modules/SlpService.rb', line 126 def slp_type @slp_type end |
- (Object) slp_url (readonly)
Returns the value of attribute slp_url
126 127 128 |
# File '../../src/modules/SlpService.rb', line 126 def slp_url @slp_url end |
Class Method Details
+ (Object) create(params)
120 121 122 123 |
# File '../../src/modules/SlpService.rb', line 120 def self.create params service = new(params) return service if service.verified? end |
Instance Method Details
- (Boolean) verified?
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File '../../src/modules/SlpService.rb', line 142 def verified? params.all? do |key, value| if respond_to?(key) result = send(key).to_s result.match(/#{value}/i) elsif attributes.respond_to?(key) result = attributes.send(key).to_s result.match(/#{value}/i) else true end end end |