lib/ip2proxy_ruby.rb in ip2proxy_ruby-1.0.2 vs lib/ip2proxy_ruby.rb in ip2proxy_ruby-1.0.3

- old
+ new

@@ -7,11 +7,11 @@ require_relative 'ip2proxy_ruby/ip2proxy_record' class Ip2proxy attr_accessor :record_class4, :record_class6, :v4, :file, :db_index, :count, :base_addr, :ipno, :record, :database, :columns, :ip_version, :ipv4databasecount, :ipv4databaseaddr, :ipv4indexbaseaddr, :ipv6databasecount, :ipv6databaseaddr, :ipv6indexbaseaddr, :databaseyear, :databasemonth, :databaseday - VERSION = '1.0.2' + VERSION = '1.0.3' FIELD_NOT_SUPPORTED = 'NOT SUPPORTED' INVALID_IP_ADDRESS = 'INVALID IP ADDRESS' def open(url) self.file = File.open(File.expand_path url, 'rb') @@ -35,19 +35,19 @@ def close() self.file.close end - def getModuleVersion() + def get_module_version() return VERSION end - def getPackageVersion() + def get_package_version() return (self.db_index).to_s end - def getDatabaseVersion() + def get_database_version() return (self.databaseyear).to_s + "." + (self.databasemonth).to_s + "." + (self.databaseday).to_s end def get_record(ip) ipno = IPAddr.new(ip, Socket::AF_UNSPEC) @@ -75,11 +75,11 @@ else return self.record = bsearch(0, self.count, ipnum, self.base_addr, col_length) end end - def getCountryShort(ip) + def get_country_short(ip) valid = !(IPAddr.new(ip) rescue nil).nil? if valid rec = get_record(ip) if !(rec.nil?) country_short = (defined?(rec.country_short) && rec.country_short != '') ? rec.country_short : FIELD_NOT_SUPPORTED @@ -90,11 +90,11 @@ country_short = INVALID_IP_ADDRESS end return country_short end - def getCountryLong(ip) + def get_country_long(ip) valid = !(IPAddr.new(ip) rescue nil).nil? if valid rec = get_record(ip) if !(rec.nil?) country_long = (defined?(rec.country_long) && rec.country_long != '') ? rec.country_long : FIELD_NOT_SUPPORTED @@ -105,11 +105,11 @@ country_long = INVALID_IP_ADDRESS end return country_long end - def getRegion(ip) + def get_region(ip) valid = !(IPAddr.new(ip) rescue nil).nil? if valid rec = get_record(ip) if !(rec.nil?) region = (defined?(rec.region) && rec.region != '') ? rec.region : FIELD_NOT_SUPPORTED @@ -120,11 +120,11 @@ region = INVALID_IP_ADDRESS end return region end - def getCity(ip) + def get_city(ip) valid = !(IPAddr.new(ip) rescue nil).nil? if valid rec = get_record(ip) if !(rec.nil?) city = (defined?(rec.city) && rec.city != '') ? rec.city : FIELD_NOT_SUPPORTED @@ -135,11 +135,11 @@ city = INVALID_IP_ADDRESS end return city end - def getISP(ip) + def get_isp(ip) valid = !(IPAddr.new(ip) rescue nil).nil? if valid rec = get_record(ip) if !(rec.nil?) isp = (defined?(rec.isp) && rec.isp != '') ? rec.isp : FIELD_NOT_SUPPORTED @@ -150,11 +150,11 @@ isp = INVALID_IP_ADDRESS end return isp end - def getProxyType(ip) + def get_proxytype(ip) valid = !(IPAddr.new(ip) rescue nil).nil? if valid rec = get_record(ip) if !(rec.nil?) proxytype = (defined?(rec.proxytype) && rec.proxytype != '') ? rec.proxytype : FIELD_NOT_SUPPORTED @@ -165,11 +165,11 @@ proxytype = INVALID_IP_ADDRESS end return proxytype end - def isProxy(ip) + def is_proxy(ip) valid = !(IPAddr.new(ip) rescue nil).nil? if valid rec = get_record(ip) if !(rec.nil?) if self.db_index == 1 @@ -184,10 +184,10 @@ isproxy = -1 end return isproxy end - def getAll(ip) + def get_all(ip) valid = !(IPAddr.new(ip) rescue nil).nil? if valid rec = get_record(ip) if !(rec.nil?) country_short = (defined?(rec.country_short) && rec.country_short != '') ? rec.country_short : FIELD_NOT_SUPPORTED \ No newline at end of file