Compare projects
Project comparisons allow you to view any selection of projects side by side just like they're shown on regular categories or in search results. You can try out an example or start yourself by adding a library to the comparison via the input below. You can also easily share your current comparison with others by sending the URL of the current page.
0.0
IPLibrary
=========
顾名思义,这是一个ip库
Example
=======
本gem中已经带有ip库,默认是gem目录下doc/ip_libraries.txt
默认ip库的格式以IPLibrary::Configuration.separator分组
各组第一行为ip头(192.168.1.1的ip头为192),其他行各列以英文逗号隔开
各列分别是:起始ip, 结束ip, 省份, 城市, 县区, 行政划分最小字段的拼音(如果有县区则为县区的拼音)
当然,您也可以有自己的ip库
设置ip库的path: IPLibrary::Configuration.file_path = '/home/doc/ip_libraries.txt'
而且,您也可以设置ip库中的列的含义,start_ip、end_ip两列必须有,且必须依次为1、2列
设置其他列:IPLibrary::Configuration.optional_columns = [:province, :city, :district, :pinyin]
除了1、2列,其他列一次为province、city、district、pinyin
然后会动态生成方法:
IPLibrary::Base#ip2province
IPLibrary::Base#ip2city
IPLibrary::Base#ip2district
IPLibrary::Base#ip2pinyin
=============================================
IPLibrary::Base 的方法有:
IPLibrary::Base.ip2province('123.132.254.134')
IPLibrary::Base.ip2province(2072313478)
#=> "山东"
IPLibrary::Base.ip2city('123.132.254.134')
IPLibrary::Base.ip2city(2072313478)
#=> "临沂"
IPLibrary::Base.ip2district('123.132.254.134')
IPLibrary::Base.ip2district(2072313478)
# => ""
IPLibrary::Base.ip2pinyin('123.132.254.134')
IPLibrary::Base.ip2pinyin(2072313478)
#=> "linyi"
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025