class Name
Extensions to the Resolv::DNS::Name
class.
Definitions
def with_origin(origin, absolute = true)
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).
Signature
-
parameter
origin
Array | String
The origin to append to the name.
-
parameter
absolute
Boolean
If true, the name will be made absolute.
Implementation
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
def without_origin(origin, absolute = false)
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).
Signature
-
parameter
origin
Array | String
The origin to remove from the name.
-
parameter
absolute
Boolean
If true, the name will be made absolute.
-
raises
OriginError
If the name does not end with the specified origin.
Implementation
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