Class: MelissaData::NativeObject::IpLocator
- Defined in:
- lib/melissadata/native_object/ip_locator.rb
Instance Attribute Summary
Attributes inherited from Base
#data_dir, #input, #obj, #output, #result_codes, #results_string
Instance Method Summary collapse
- #assign_values ⇒ Object
-
#initialize(opts = {}) ⇒ IpLocator
constructor
A new instance of IpLocator.
- #parse_input ⇒ Object
Methods inherited from Base
#license, #process, #process_result_codes, #valid_input?
Constructor Details
#initialize(opts = {}) ⇒ IpLocator
Returns a new instance of IpLocator.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/melissadata/native_object/ip_locator.rb', line 5 def initialize(opts={}) @obj = MdIpLocatorRubyWrapper::MdIpLocator.new obj.SetPathToIpLocatorFiles(data_dir) @result_codes = [ ['IS01', "IP Address found in database"], ['IS02', "IP Address unknown"], ['IE01', "IP Address was empty or not well formed"] ] @defaults = { :ip => '' } # At least one of these needs to be present @required_fields = [:ip] super end |
Instance Method Details
#assign_values ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/melissadata/native_object/ip_locator.rb', line 29 def assign_values @output = { :domain_name => obj.GetDomainName, :isp => obj.GetISP, :city => obj.GetCity, :region => obj.GetRegion, :zip => obj.GetZip, :country => obj.GetCountry, :country_abbrev => obj.GetCountryAbbreviation, :lat => obj.GetLatitude, :lng => obj.GetLongitude } end |
#parse_input ⇒ Object
25 26 27 |
# File 'lib/melissadata/native_object/ip_locator.rb', line 25 def parse_input obj.LocateIpAddress(input[:ip].to_s) end |