Skip to content

Commit

Permalink
Fixed Performance/RangeInclude
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jun 9, 2016
1 parent a8def0f commit 6ce458c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions library/types/src/modules/IP.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def reserved4(ip)
return true if ip.start_with?("192.19.")

# all from 224. is covered by RFC#5771 and RFC#5735
return true if (224..255).include?(ip.split(".").first.to_i)
return true if (224..255).cover?(ip.split(".").first.to_i)

false
end
Expand Down Expand Up @@ -393,7 +393,7 @@ def private_carrier_grade_nat?(ip)
return false unless ip.start_with?("100.")

second_part = ip.split(".")[1].to_i
(64..127).include?(second_part)
(64..127).cover?(second_part)
end

def private_network?(ip)
Expand All @@ -407,14 +407,14 @@ def private_network?(ip)
return false unless ip.start_with?("172.")

second_part = ip.split(".")[1].to_i
(16..31).include?(second_part)
(16..31).cover?(second_part)
end

def ds_lite_address?(ip)
return false unless ip.start_with?("192.0.0.")

fourth_part = ip.split(".")[3].to_i
(0..7).include?(fourth_part)
(0..7).cover?(fourth_part)
end
end

Expand Down

0 comments on commit 6ce458c

Please sign in to comment.