In Files
- resolv.rb
Parent
Object
Class/Module Index
- Resolv
- Resolv::DNS
- Resolv::DNS::Config
- Resolv::DNS::Config::NXDomain
- Resolv::DNS::Config::OtherResolvError
- Resolv::DNS::DecodeError
- Resolv::DNS::EncodeError
- Resolv::DNS::Name
- Resolv::DNS::Query
- Resolv::DNS::Requester
- Resolv::DNS::Requester::RequestError
- Resolv::DNS::Resource
- Resolv::DNS::Resource::ANY
- Resolv::DNS::Resource::CNAME
- Resolv::DNS::Resource::DomainName
- Resolv::DNS::Resource::Generic
- Resolv::DNS::Resource::HINFO
- Resolv::DNS::Resource::IN
- Resolv::DNS::Resource::IN::A
- Resolv::DNS::Resource::IN::AAAA
- Resolv::DNS::Resource::IN::SRV
- Resolv::DNS::Resource::IN::WKS
- Resolv::DNS::Resource::LOC
- Resolv::DNS::Resource::MINFO
- Resolv::DNS::Resource::MX
- Resolv::DNS::Resource::NS
- Resolv::DNS::Resource::PTR
- Resolv::DNS::Resource::SOA
- Resolv::DNS::Resource::TXT
- Resolv::Hosts
- Resolv::IPv4
- Resolv::IPv6
- Resolv::LOC
- Resolv::LOC::Alt
- Resolv::LOC::Coord
- Resolv::LOC::Size
- Resolv::MDNS
- Resolv::ResolvError
- Resolv::ResolvTimeout
Resolv::Hosts
Resolv::Hosts is a hostname resolver that uses the system hosts file.
Constants
Public Class Methods
new(filename = DefaultFileName)
Creates a new Resolv::Hosts, using
filename
for its data source.
# File resolv.rb, line 181 def initialize(filename = DefaultFileName) @filename = filename @mutex = Mutex.new @initialized = nil end
Public Instance Methods
each_address(name, &proc)
Iterates over all IP addresses for name
retrieved from the
hosts file.
# File resolv.rb, line 238 def each_address(name, &proc) lazy_initialize if @name2addr.include?(name) @name2addr[name].each(&proc) end end
each_name(address, &proc)
Iterates over all hostnames for address
retrieved from the
hosts file.
# File resolv.rb, line 265 def each_name(address, &proc) lazy_initialize if @addr2name.include?(address) @addr2name[address].each(&proc) end end
getaddress(name)
Gets the IP address of name
from the hosts file.
# File resolv.rb, line 221 def getaddress(name) each_address(name) {|address| return address} raise ResolvError.new("#{@filename} has no name: #{name}") end
getaddresses(name)
Gets all IP addresses for name
from the hosts file.
# File resolv.rb, line 229 def getaddresses(name) ret = [] each_address(name) {|address| ret << address} return ret end