Class: SecurityGuard::CountryIps

Inherits:
Object
  • Object
show all
Includes:
SecurityGuard::Concerns::AcceptsFromFile, SecurityGuard::Concerns::Initializable
Defined in:
lib/security_guard/country_ips.rb

Instance Method Summary collapse

Methods included from SecurityGuard::Concerns::Initializable

included, #initializable_attrs

Methods included from SecurityGuard::Concerns::AcceptsFromFile

included

Constructor Details

#initialize(args = nil) ⇒ CountryIps

Returns a new instance of CountryIps.



9
10
11
12
# File 'lib/security_guard/country_ips.rb', line 9

def initialize(args = nil)
  @geoip ||= Utils::GeoIps.new(Utils::Files.load('GeoIP.dat'))
  initializable_attrs args
end

Instance Method Details

#resultObject



14
15
16
17
18
19
20
21
# File 'lib/security_guard/country_ips.rb', line 14

def result
  country_ips = []
  ips.each do |ip|
    @geoip.ip_address = ip
    country_ips << ip if countries.include?(@geoip.country_name)
  end
  country_ips.sort
end