 class Resolv 

Parent:
Object
  Resolv is a thread-aware DNS resolver library written in Ruby. Resolv can handle multiple DNS requests concurrently without blocking the entire Ruby interpreter. See also resolv-replace.rb to replace the libc resolver with Resolv. Resolv can look up various DNS resources using the DNS module directly. Examples: p Resolv.getaddress "www.ruby-lang.org"
p Resolv.getname "217-757-9687"

Resolv8b7c:f320:99b9:690f:4595:cd17:293a:c069NS.open do |dns|
  ress = dns.getresources "www.ruby-lang.org", Resolv8b7c:f320:99b9:690f:4595:cd17:293a:c069NS8b7c:f320:99b9:690f:4595:cd17:293a:c069Resour8b7c:f320:99b9:690f:4595:cd17:293a:c069IN8b7c:f320:99b9:690f:4595:cd17:293a:c069
  p ress.map { |r| r.address }
  ress = dns.getresources "ruby-lang.org", Resolv8b7c:f320:99b9:690f:4595:cd17:293a:c069NS8b7c:f320:99b9:690f:4595:cd17:293a:c069Resour8b7c:f320:99b9:690f:4595:cd17:293a:c069IN8b7c:f320:99b9:690f:4595:cd17:293a:c069MX
  p ress.map { |r| [r.exchange.to_s, r.preference] }
end
 Bugs 
 NIS is not supported. 
 /etc/nsswitch.conf is not supported. 
     Constants   AddressRegex 

Address Regexp to use for matching IP addresses. 
DefaultResolver 

Default resolver to use for Resolv class methods. 
    Public Class Methods    each_address(name, &block) Show source  
 # File lib/resolv.rb, line 58
def self.each_address(name, &block)
  DefaultResolver.each_address(name, &block)
end  Iterates over all IP addresses for name.     each_name(address, &proc) Show source  
 # File lib/resolv.rb, line 79
def self.each_name(address, &proc)
  DefaultResolver.each_name(address, &proc)
end  Iterates over all hostnames for address.     getaddress(name) Show source  
 # File lib/resolv.rb, line 44
def self.getaddress(name)
  DefaultResolver.getaddress(name)
end  Looks up the first IP address for name.     getaddresses(name) Show source  
 # File lib/resolv.rb, line 51
def self.getaddresses(name)
  DefaultResolver.getaddresses(name)
end  Looks up all IP address for name.     getname(address) Show source  
 # File lib/resolv.rb, line 65
def self.getname(address)
  DefaultResolver.getname(address)
end  Looks up the hostname of address.     getnames(address) Show source  
 # File lib/resolv.rb, line 72
def self.getnames(address)
  DefaultResolver.getnames(address)
end  Looks up all hostnames for address.     new(resolvers=[Hosts.new, DNS.new]) Show source  
 # File lib/resolv.rb, line 86
def initialize(resolvers=[Hosts.new, DNS.new])
  @resolvers = resolvers
end  Creates a new Resolv using resolvers.      Public Instance Methods    each_address(name) { |name| ... } Show source  
 # File lib/resolv.rb, line 110
def each_address(name)
  if AddressRegex =~ name
    yield name
    return
  end
  yielded = false
  @resolvers.each {|r|
    r.each_address(name) {|address|
      yield address.to_s
      yielded = true
    }
    return if yielded
  }
end  Iterates over all IP addresses for name.     each_name(address) { |name| ... } Show source  
 # File lib/resolv.rb, line 145
def each_name(address)
  yielded = false
  @resolvers.each {|r|
    r.each_name(address) {|name|
      yield name.to_s
      yielded = true
    }
    return if yielded
  }
end  Iterates over all hostnames for address.     getaddress(name) Show source  
 # File lib/resolv.rb, line 93
def getaddress(name)
  each_address(name) {|address| return address}
  raise ResolvError.new("no address for #{name}")
end  Looks up the first IP address for name.     getaddresses(name) Show source  
 # File lib/resolv.rb, line 101
def getaddresses(name)
  ret = []
  each_address(name) {|address| ret << address}
  return ret
end  Looks up all IP address for name.     getname(address) Show source  
 # File lib/resolv.rb, line 128
def getname(address)
  each_name(address) {|name| return name}
  raise ResolvError.new("no name for #{address}")
end  Looks up the hostname of address.     getnames(address) Show source  
 # File lib/resolv.rb, line 136
def getnames(address)
  ret = []
  each_name(address) {|name| ret << name}
  return ret
end  Looks up all hostnames for address.    

    Ruby Core © 1993–2017 Yukihiro MatsumotoLicensed under the Ruby License.Ruby Standard Library 
{'path': 'public/docs/ruby~2.3/resolv.html', 'source': 'DevDocs.IO'}