Class: Resolv::IPv4
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/resolv.rb |
Overview
A DNS IPv4
address.
Constant Summary
-
Regex =
# File 'lib/resolv.rb', line 2319/\A(#{Regex256})\.(#{Regex256})\.(#{Regex256})\.(#{Regex256})\z/
-
Regex256 =
Regular expression
IPv4
addresses must match./0 |1(?:[0-9][0-9]?)? |2(?:[0-4][0-9]?|5[0-5]?|[6-9])? |[3-9][0-9]?/x
Class Method Summary
Instance Attribute Summary
-
#address
readonly
The raw
IPv4
address as a String.
Instance Method Summary
Class Method Details
.create(arg)
[ GitHub ]# File 'lib/resolv.rb', line 2321
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
Instance Attribute Details
#address (readonly)
The raw IPv4
address as a String.
# File 'lib/resolv.rb', line 2355
attr_reader :address
Instance Method Details
#to_name
Turns this IPv4
address into a DNS::Name.