class IpRestriction::IpChecker
Attributes
ranges[R]
Public Class Methods
new(ranges)
click to toggle source
# File lib/ip_restriction/ip_checker.rb, line 7 def initialize(ranges) @ranges = ranges end
Public Instance Methods
allowed?(ip)
click to toggle source
# File lib/ip_restriction/ip_checker.rb, line 11 def allowed?(ip) ranges.any? do |range_or_ip| IPAddr.new(range_or_ip).include?(IPAddr.new(ip)) end end