Method: IPAddress::IPv4#loopback?

Defined in:
lib/ipaddress/ipv4.rb

#loopback?Boolean

Checks if an IPv4 address objects belongs to a loopback network RFC1122

Example:

ip = IPAddress "127.0.0.1"
ip.loopback?
  #=> true

Returns:

  • (Boolean)


651
652
653
# File 'lib/ipaddress/ipv4.rb', line 651

def loopback?
  [self.class.new("127.0.0.0/8")].any? {|i| i.include? self}
end