[![Latest Stable Version](https://img.shields.io/gem/v/ip2location_ruby.svg)](https://rubygems.org/gems/ip2location_ruby) [![Total Downloads](https://img.shields.io/gem/dt/ip2location_ruby.svg)](https://rubygems.org/gems/ip2location_ruby) # IP2Location Ruby Library This is IP2Location Ruby library that enables the user to find the country, region or state, city, latitude and longitude, US ZIP code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, and usage type by IP address or hostname originates from. The library reads the geo location information from **IP2Location BIN data** file or web service. Supported IPv4 and IPv6 address. For more details, please visit: [https://www.ip2location.com/developers/ruby](https://www.ip2location.com/developers/ruby) # Usage You can check the **example.rb** file to learn more about usage. ## BIN Database Below is the description of the functions available in the **BIN Database** lookup. | Function Name | Description | |---|---| | open | Open the IP2Location BIN data for lookup. | | close | Close and clean up the file pointer. | | get_all | Return the geolocation information in array. | | get_country_short | Return the ISO3166-1 country code (2-digits) of the IP address. | | get_country_long | Return the ISO3166-1 country name of the IP address. | | get_region | Return the ISO3166-2 region name of the IP address. Please visit [ISO3166-2 Subdivision Code](https://www.ip2location.com/free/iso3166-2) for the information of ISO3166-2 supported | | get_city | Return the city name of the IP address. | | get_latitude | Return the city latitude of the IP address. | | get_longitude | Return the city longtitude of the IP address. | | get_isp | Return the ISP name of the IP address. | | get_domain | Return the domain name of IP address. | | get_zipcode | Return the zipcode of the city. | | get_timezone | Return the UTC time zone (with DST supported). | | get_netspeed | Return the Internet connection type. | | get_iddcode | Return the IDD prefix to call the city from another country. | | get_areacode | Return the area code of the city. | | get_weathercode | Return the nearest weather observation station code. | | get_weathername | Return the nearest weather observation station name. | | get_mcc | Return the Mobile Country Codes (MCC). | | get_mnc | Return the Mobile Network Code (MNC). | | get_mobilebrand | Commercial brand associated with the mobile carrier. | | get_elevation | Return average height of city above sea level in meters (m). | | get_usagetype | Return the ISP's usage type of IP address. | ## Web Service Below is the description of the functions available in the **Web Service** lookup. | Function Name | Description | |---|---| | Constructor | Expect 3 input parameters: