Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
IPAddr#ipv4_mapped
() -> ::IPAddr
ipv4_mapped
lib/ipaddr.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/ipaddr.rb, line 358
def ipv4_mapped
if !ipv4?
raise InvalidAddressError, "not an IPv4 address: #{@addr}"
end
clone = self.clone.set(@addr | 0xffff00000000, Socket::AF_INET6)
clone.instance_variable_set(:@mask_addr, @mask_addr | 0xffffffffffffffffffffffff00000000)
clone
end
Returns a new ipaddr built by converting the native IPv4 address into an IPv4-mapped IPv6 address.