Resolv::IPv4
class Resolv::IPv4
父类:Object
Resolv :: DNS IPv4地址。
常量
正则表达式Regex256
正则表达式IPv4地址必须匹配。
属性
addressR
原始IPv4地址作为字符串。
公共类方法
创建(arg)显示源
# File lib/resolv.rb, line 2325
def self.create(arg)
case arg
when IPv4
return arg
when Regex
if (0..255) === (a = $1.to_i) &&
(0..255) === (b = $2.to_i) &&
(0..255) === (c = $3.to_i) &&
(0..255) === (d = $4.to_i)
return self.new([a, b, c, d].pack("CCCC"))
else
raise ArgumentError.new("IPv4 address with invalid value: " + arg)
end
else
raise ArgumentError.new("cannot interpret as IPv4 address: #{arg.inspect}")
end
end
公共实例方法
to_name()显示源
将此IPv4地址转换为Resolv :: DNS :: Name。
# File lib/resolv.rb, line 2372
def to_name
return DNS::Name.create(
'%d.%d.%d.%d.in-addr.arpa.' % @address.unpack('CCCC').reverse)
end