Class: Resolv::DNS::Name
- Inherits:
-
Object
- Object
- Resolv::DNS::Name
- Defined in:
- lib/async/dns/extensions/resolv.rb
Overview
Extensions to the ‘Resolv::DNS::Name` class.
Instance Method Summary collapse
-
#with_origin(origin, absolute = true) ⇒ Object
Computes the name, typically absolute, with the specified origin as a suffix.
-
#without_origin(origin, absolute = false) ⇒ Object
Compute the name, typically relative, without the specified origin suffix.
Instance Method Details
#with_origin(origin, absolute = true) ⇒ Object
Computes the name, typically absolute, with the specified origin as a suffix. If the origin is nil, don’t change the name, but change it to absolute (as specified).
48 49 50 51 52 53 54 |
# File 'lib/async/dns/extensions/resolv.rb', line 48 def with_origin(origin, absolute = true) return self.class.new(@labels, absolute) if origin == nil origin = Label.split(origin) if String === origin return self.class.new(@labels + origin, absolute) end |
#without_origin(origin, absolute = false) ⇒ Object
Compute the name, typically relative, without the specified origin suffix. If the origin is nil, don’t change the name, but change it to absolute (as specified).
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/async/dns/extensions/resolv.rb', line 62 def without_origin(origin, absolute = false) return self.class.new(@labels, absolute) if origin == nil origin = Label.split(origin) if String === origin if @labels.last(origin.length) == origin return self.class.new(@labels.first(@labels.length - origin.length), absolute) else raise OriginError.new("#{self} does not end with #{origin.join('.')}") end end |