Skip to content

Commit

Permalink
Allow IPRange#include? to accept String arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
erran committed Apr 2, 2015
1 parent 11563fb commit 45118a2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/nexpose/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -723,11 +723,14 @@ def eql?(other)
@from == other.from && @to == other.to
end

def include?(single_ip)
return false unless single_ip.respond_to? :from
def include?(subset)
from = IPAddr.new(@from)
to = @to.nil? ? from : IPAddr.new(@to)
other = IPAddr.new(single_ip)
if subset.respond_to?(:from)
other = IPAddr.new(subset.from)
else
other = IPAddr.new(subset)
end

if other < from
false
Expand Down

0 comments on commit 45118a2

Please sign in to comment.