Class: IpLocationService::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/ip_location_service/region.rb

Overview

Represents a region as used within the IpAddressLocation class in the context of the IpLocationService.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#country_codeObject

Returns the value of attribute country_code.



5
6
7
# File 'lib/ip_location_service/region.rb', line 5

def country_code
  @country_code
end

#region_codeObject

Returns the value of attribute region_code.



5
6
7
# File 'lib/ip_location_service/region.rb', line 5

def region_code
  @region_code
end

#region_nameObject

Returns the value of attribute region_name.



5
6
7
# File 'lib/ip_location_service/region.rb', line 5

def region_name
  @region_name
end

Class Method Details

.build_from_xml(xml_doc) ⇒ Object

Static methods



13
14
15
16
17
18
19
20
21
# File 'lib/ip_location_service/region.rb', line 13

def self.build_from_xml(xml_doc)
  region = Region.new      
  if xml_doc && xml_doc.size > 0 then       
    region.country_code = IpLocationService.xpath_query(xml_doc, "countryCode", false).to_s
    region.region_code  = IpLocationService.xpath_query(xml_doc, "regionCode", false).to_s
    region.region_name  = IpLocationService.xpath_query(xml_doc, "regionName", false).to_s
  end      
  return region
end

Instance Method Details

#to_sObject



7
8
9
# File 'lib/ip_location_service/region.rb', line 7

def to_s
  "Region: #{@country_code.to_s}, #{@region_code.to_s}, #{@region_name.to_s}"
end