Skip to content

matsumotory/mruby-geoip

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

mruby-geoip Build Status

GeoIPCity class using GeoIPCity.dat for mruby

install by mrbgems

  • add conf.gem line to build_config.rb
MRuby::Build.new do |conf|

    # ... (snip) ...

    conf.gem :github => 'matsumoto-r/mruby-geoip'
end

example

db_path = "/usr/share/GeoIP/GeoIPCity.dat"
host = "www.google.com"

geoip = GeoIP.new db_path

# You can use record_by_addr when using IP address into host
geoip.record_by_name host

geoip.country_code        #=> "US"
geoip.region              #=> "CA"
geoip.region_name         #=> "California"
geoip.city                #=> "Mountain View"
geoip.postal_code         #=> "94043"
geoip.latitude.round(4)   #=> 37.4192
geoip.longitude.round(4)  #=> -122.0574
geoip.metro_code          #=> 807
geoip.area_code           #=> 650
geoip.time_zone           #=> "America/Los_Angeles"

License

under the MIT License:

  • see LICENSE file

About

GeoIP mrbgem using GeoIPCity.dat

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published