Module: IPmetric
- Included in:
- ChefAB::TimeIPBasedUpgrader
- Defined in:
- lib/chef-ab/ip_metric.rb
Instance Method Summary collapse
Instance Method Details
#ip_metric(ip_ref, ip) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/chef-ab/ip_metric.rb', line 5 def ip_metric(ip_ref, ip) ip1 = IPAddress.parse(ip_ref) ip2 = IPAddress.parse(ip) dist = (0..32).to_a.reverse.bsearch do |mask| ip1.prefix = mask ip1.include?(ip2) end 32 - dist end |