Class: Resolv::DNS::Name
- Inherits:
-
Object
- Object
- Resolv::DNS::Name
- Defined in:
- lib/async/dns/extensions/resolv.rb
Instance Method Summary collapse
- #inspect ⇒ Object
- #to_s ⇒ Object
-
#with_origin(origin, absolute = true) ⇒ Object
Return the name, typically absolute, with the specified origin as a suffix.
-
#without_origin(origin, absolute = false) ⇒ Object
Return the name, typically relative, without the specified origin suffix.
Instance Method Details
#inspect ⇒ Object
57 58 59 |
# File 'lib/async/dns/extensions/resolv.rb', line 57 def inspect "#<#{self.class}: #{self.to_s}>" end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/async/dns/extensions/resolv.rb', line 53 def to_s "#{@labels.join('.')}#{@absolute ? '.' : ''}" end |
#with_origin(origin, absolute = true) ⇒ Object
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).
62 63 64 65 66 67 68 |
# 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) ⇒ Object
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).
71 72 73 74 75 76 77 78 79 80 81 |
# 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 |