From 4c759982e386e2ebdd99346c67caef3dce55e583 Mon Sep 17 00:00:00 2001 From: Mike Mackintosh Date: Sun, 22 Mar 2015 10:53:41 -0400 Subject: added multicast --- lib/ipaddress/ipv4.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/ipaddress/ipv4.rb b/lib/ipaddress/ipv4.rb index a32a4a0..38afbb1 100644 --- a/lib/ipaddress/ipv4.rb +++ b/lib/ipaddress/ipv4.rb @@ -584,6 +584,20 @@ module IPAddress; self.class.new("192.168.0.0/16")].any? {|i| i.include? self} end + # + # Checks if an IPv4 address objects belongs + # to a multicast network RFC3171 + # + # Example: + # + # ip = IPAddress "224.0.0.0/4" + # ip.multicast? + # #=> true + # + def multicast? + [self.class.new("224.0.0.0/4")].any? {|i| i.include? self} + end + # # Returns the IP address in in-addr.arpa format # for DNS lookups -- cgit v1.2.1