Class: SecurityGuard::Utils::GeoIps

Inherits:
Object
  • Object
show all
Defined in:
lib/security_guard/utils/geo_ips.rb

Constant Summary collapse

VALID_IP_ADDRESS =
/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(geo_data_file, ip_address = nil) ⇒ GeoIps

Returns a new instance of GeoIps.



10
11
12
13
# File 'lib/security_guard/utils/geo_ips.rb', line 10

def initialize(geo_data_file, ip_address = nil)
  @geoip ||= GeoIP.new(geo_data_file)
  self.ip_address = ip_address
end

Instance Attribute Details

#ip_addressObject

Returns the value of attribute ip_address.



6
7
8
# File 'lib/security_guard/utils/geo_ips.rb', line 6

def ip_address
  @ip_address
end

Instance Method Details

#countryObject



15
16
17
# File 'lib/security_guard/utils/geo_ips.rb', line 15

def country
  @geoip.country(ip_address)
end

#country_nameObject



19
20
21
# File 'lib/security_guard/utils/geo_ips.rb', line 19

def country_name
  country.country_name
end