class Resolv::DNS::Name

Public Instance Methods

inspect() click to toggle source
# File lib/async/dns/extensions/resolv.rb, line 57
def inspect
        "#<#{self.class}: #{self.to_s}>"
end
to_s() click to toggle source
# File lib/async/dns/extensions/resolv.rb, line 53
def to_s
        "#{@labels.join('.')}#{@absolute ? '.' : ''}"
end
with_origin(origin, absolute = true) click to toggle source

Return 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).

# File lib/async/dns/extensions/resolv.rb, line 62
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) click to toggle source

Return 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).

# File lib/async/dns/extensions/resolv.rb, line 71
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