Class: SemanticCrawler::GeoNames::Country

Inherits:
Object
  • Object
show all
Defined in:
lib/semantic_crawler/geo_names/country.rb

Overview

Represents Food and Agriculture information about one country.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(new_latitude, new_longitude) ⇒ Country

Returns a new instance of Country.



14
15
16
17
# File 'lib/semantic_crawler/geo_names/country.rb', line 14

def initialize(new_latitude, new_longitude)
    @latitude = new_latitude
    @longitude = new_longitude
end

Instance Attribute Details

#latitudeObject (readonly)

The input latitude



8
9
10
# File 'lib/semantic_crawler/geo_names/country.rb', line 8

def latitude
  @latitude
end

#longitudeObject (readonly)

The input longitude



12
13
14
# File 'lib/semantic_crawler/geo_names/country.rb', line 12

def longitude
  @longitude
end

Instance Method Details

#get_country_codeObject

Returns an ISO 3166-1 alpha-2 country code



20
21
22
# File 'lib/semantic_crawler/geo_names/country.rb', line 20

def get_country_code
    Geonames::WebService.country_code @latitude, @longitude
end

#get_country_nameObject

Returns the name of the country



25
26
27
28
# File 'lib/semantic_crawler/geo_names/country.rb', line 25

def get_country_name
    subdivision = Geonames::WebService.country_subdivision @latitude, @longitude
    subdivision.country_name
end

#get_factbook_countrySemanticCrawler::Factbook::Country

Returns A Factbook country object.

Returns:



37
38
39
# File 'lib/semantic_crawler/geo_names/country.rb', line 37

def get_factbook_country
    SemanticCrawler::Factbook::Country.new get_country_name
end

#get_fao_countrySemanticCrawler::Fao::Country

Returns A Food and Agriculture country object.

Returns:



42
43
44
# File 'lib/semantic_crawler/geo_names/country.rb', line 42

def get_fao_country
    SemanticCrawler::Fao::Country.new get_country_name
end

#get_freebase_countrySemanticCrawler::Freebase::Country

Returns A Freebase country object.

Returns:



47
48
49
# File 'lib/semantic_crawler/geo_names/country.rb', line 47

def get_freebase_country
    SemanticCrawler::Freebase::Country.new get_country_name
end

#get_wikipedia_articlesObject

Returns a Wikipedia object that contains a link to the article, summary and many more fields.



32
33
34
# File 'lib/semantic_crawler/geo_names/country.rb', line 32

def get_wikipedia_articles
    Geonames::WebService.find_nearby_wikipedia :lat => @latitude, :long => @longitude
end