Class: IpLocationService::IpAddressLocation
- Inherits:
-
Object
- Object
- IpLocationService::IpAddressLocation
- Defined in:
- lib/ip_location_service/ip_address_location.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#ip_type ⇒ Object
Returns the value of attribute ip_type.
-
#is_in_city ⇒ Object
Returns the value of attribute is_in_city.
-
#is_in_geo ⇒ Object
Returns the value of attribute is_in_geo.
-
#is_in_region ⇒ Object
Returns the value of attribute is_in_region.
-
#radius ⇒ Object
Returns the value of attribute radius.
Class Method Summary collapse
-
.build_from_xml(xml_doc) ⇒ Object
Builds an IpAddressLocation object from a given xml document.
Instance Method Summary collapse
-
#initialize ⇒ IpAddressLocation
constructor
A new instance of IpAddressLocation.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ IpAddressLocation
Returns a new instance of IpAddressLocation.
6 7 8 9 10 11 12 13 |
# File 'lib/ip_location_service/ip_address_location.rb', line 6 def initialize @address = nil @ip_type = nil @is_in_region = nil @is_in_city = nil @is_in_geo = nil @radius = nil end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
4 5 6 |
# File 'lib/ip_location_service/ip_address_location.rb', line 4 def address @address end |
#ip_type ⇒ Object
Returns the value of attribute ip_type.
4 5 6 |
# File 'lib/ip_location_service/ip_address_location.rb', line 4 def ip_type @ip_type end |
#is_in_city ⇒ Object
Returns the value of attribute is_in_city.
4 5 6 |
# File 'lib/ip_location_service/ip_address_location.rb', line 4 def is_in_city @is_in_city end |
#is_in_geo ⇒ Object
Returns the value of attribute is_in_geo.
4 5 6 |
# File 'lib/ip_location_service/ip_address_location.rb', line 4 def is_in_geo @is_in_geo end |
#is_in_region ⇒ Object
Returns the value of attribute is_in_region.
4 5 6 |
# File 'lib/ip_location_service/ip_address_location.rb', line 4 def is_in_region @is_in_region end |
#radius ⇒ Object
Returns the value of attribute radius.
4 5 6 |
# File 'lib/ip_location_service/ip_address_location.rb', line 4 def radius @radius end |
Class Method Details
.build_from_xml(xml_doc) ⇒ Object
Builds an IpAddressLocation object from a given xml document.
Parameter
xml_doc
-
XmlQueryFront object as received from a prior query of handsoap’s service response.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ip_location_service/ip_address_location.rb', line 27 def self.build_from_xml(xml_doc) ipa = IpAddressLocation.new if xml_doc then # We are passing "false" do search relative to the xml_doc position. Without this flag the resulting # xpath query would beginn with a "//" which would always look the search term relative from the beginning # of the document. This is not what we want right here. We would rather like to search relative to the # partial tree we have with xml_doc pointing to the IpAddressLocation tag of the response xml. # This is also true for Region's build method. ipa.address = IpLocationService.xpath_query(xml_doc, "ipAddress", false).to_s ipa.ip_type = IpLocationService.xpath_query(xml_doc, "ipType", false).to_s # TODO As soon as the API supports them. # ipa.radius = IpLocationService.xpath_query(xml_doc, "radius", false).to_s # ... isInGeo, isInCity region_xml_doc = IpLocationService.xpath_query(xml_doc, "isInRegion", false) ipa.is_in_region = Region.build_from_xml(region_xml_doc) end return ipa end |
Instance Method Details
#to_s ⇒ Object
15 16 17 18 19 |
# File 'lib/ip_location_service/ip_address_location.rb', line 15 def to_s ret = "Address: #{@address.to_s}, IP-Type: #{@ip_type.to_s}, #{@is_in_region.to_s}, " ret += "City: #{@is_in_city.to_s}, Geo: #{@is_in_geo.to_s}, Radius: #{@radius.to_s}" ret end |