Object
Resolv::Hosts is a hostname resolver that uses the system hosts file.
Creates a new Resolv::Hosts, using
filename
for its data source.
# File resolv.rb, line 179 def initialize(filename = DefaultFileName) @filename = filename @mutex = Thread::Mutex.new @initialized = nil end
Iterates over all IP addresses for name
retrieved from the
hosts file.
# File resolv.rb, line 236 def each_address(name, &proc) lazy_initialize @name2addr[name]&.each(&proc) end
Iterates over all hostnames for address
retrieved from the
hosts file.
# File resolv.rb, line 261 def each_name(address, &proc) lazy_initialize @addr2name[address]&.each(&proc) end
Gets the IP address of name
from the hosts file.
# File resolv.rb, line 219 def getaddress(name) each_address(name) {|address| return address} raise ResolvError.new("#{@filename} has no name: #{name}") end
Gets all IP addresses for name
from the hosts file.
# File resolv.rb, line 227 def getaddresses(name) ret = [] each_address(name) {|address| ret << address} return ret end