Method: Jamf::NetworkSegment.ip_range_width

Defined in:
lib/jamf/api/classic/api_objects/network_segment.rb

.ip_range_width(ip1, ip2) ⇒ Object

given 2 IPAddr instances, find out how ‘wide’ they are - how many IP addresses exist between them.

Raises:

  • (ArgumentError)


309
310
311
312
313
314
# File 'lib/jamf/api/classic/api_objects/network_segment.rb', line 309

def self.ip_range_width(ip1, ip2)
  raise ArgumentError, 'Parameters must be IPAddr objects' unless ip1.is_a?(IPAddr) && ip2.is_a?(IPAddr)

  low, high = [ip1, ip2].sort
  high.to_i - low.to_i
end