Module: DatxRuby

Defined in:
lib/datx_ruby.rb,
lib/datx_ruby/city.rb,
lib/datx_ruby/util.rb,
lib/datx_ruby/common.rb,
lib/datx_ruby/version.rb,
lib/datx_ruby/district.rb

Overview

解析ipip.net库, city_find:查找ip的城市, district_find: 查找ip的区县

Defined Under Namespace

Modules: Common Classes: City, District, Util

Constant Summary collapse

VERSION =
"0.0.5"

Class Method Summary collapse

Class Method Details

.city_datx_path=(path) ⇒ Object

set city datx file path Example:

>> DatxRuby.city_datx_path= "/path/data/17monipdb.datx"
=> /path/data/17monipdb.datx

Arguments:

path: (String)


18
19
20
# File 'lib/datx_ruby.rb', line 18

def self.city_datx_path=(path)
  City.datax_path= path
end

.city_find(ip) ⇒ Object

find a ip’s location Example:

>> DatxRuby.city_find("106.75.109.221")
=> ["中国", "北京", "北京"]

Arguments:

ip: (String)


38
39
40
# File 'lib/datx_ruby.rb', line 38

def self.city_find(ip)
  City.new.find(ip)
end

.district_datx_path=(path) ⇒ Object

set district datx file path Example:

>> DatxRuby.district_datx_path= "/path/data/17monipdb.datx"
=> /path/data/17monipdb.datx

Arguments:

path: (String)


28
29
30
# File 'lib/datx_ruby.rb', line 28

def self.district_datx_path=(path)
  District.datax_path= path
end

.district_find(ip) ⇒ Object

find a ip’s district Example:

>> DatxRuby.district_find("106.75.109.221")
=> ["中国", "北京", "北京"]

Arguments:

ip: (String)


48
49
50
# File 'lib/datx_ruby.rb', line 48

def self.district_find(ip)
  District.new.find(ip)
end