Class: SecurityGuard::Utils::GeoIps
- Inherits:
-
Object
- Object
- SecurityGuard::Utils::GeoIps
- 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
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
Instance Method Summary collapse
- #country ⇒ Object
- #country_name ⇒ Object
-
#initialize(geo_data_file, ip_address = nil) ⇒ GeoIps
constructor
A new instance of GeoIps.
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_address ⇒ Object
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
#country ⇒ Object
15 16 17 |
# File 'lib/security_guard/utils/geo_ips.rb', line 15 def country @geoip.country(ip_address) end |
#country_name ⇒ Object
19 20 21 |
# File 'lib/security_guard/utils/geo_ips.rb', line 19 def country_name country.country_name end |