Class: Restcountry::Country
- Inherits:
-
Object
- Object
- Restcountry::Country
- Defined in:
- lib/restcountry/country.rb
Instance Attribute Summary collapse
-
#alpha2Code ⇒ Object
readonly
Returns the value of attribute alpha2Code.
-
#alpha3Code ⇒ Object
readonly
Returns the value of attribute alpha3Code.
-
#altSpellings ⇒ Object
readonly
Returns the value of attribute altSpellings.
-
#area ⇒ Object
readonly
Returns the value of attribute area.
-
#borders ⇒ Object
readonly
Returns the value of attribute borders.
-
#callingCodes ⇒ Object
readonly
Returns the value of attribute callingCodes.
-
#capital ⇒ Object
readonly
Returns the value of attribute capital.
-
#currencies ⇒ Object
readonly
Returns the value of attribute currencies.
-
#demonym ⇒ Object
readonly
Returns the value of attribute demonym.
-
#gini ⇒ Object
readonly
Returns the value of attribute gini.
-
#languages ⇒ Object
readonly
Returns the value of attribute languages.
-
#latlng ⇒ Object
readonly
Returns the value of attribute latlng.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nativeName ⇒ Object
readonly
Returns the value of attribute nativeName.
-
#population ⇒ Object
readonly
Returns the value of attribute population.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#relevance ⇒ Object
readonly
Returns the value of attribute relevance.
-
#subregion ⇒ Object
readonly
Returns the value of attribute subregion.
-
#timezones ⇒ Object
readonly
Returns the value of attribute timezones.
-
#topLevelDomain ⇒ Object
readonly
Returns the value of attribute topLevelDomain.
-
#translations ⇒ Object
readonly
Returns the value of attribute translations.
Class Method Summary collapse
- .all ⇒ Object
- .find(name, fulltext = false) ⇒ Object
- .find_by_callingcode(callingcode) ⇒ Object
- .find_by_capital(capital) ⇒ Object
- .find_by_countrycode(countrycode) ⇒ Object
- .find_by_currency(currency) ⇒ Object
- .find_by_lang(lang) ⇒ Object
- .find_by_name(name, fulltext = false) ⇒ Object
- .find_by_region(region) ⇒ Object
- .find_by_subregion(subregion) ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Country
constructor
A new instance of Country.
Constructor Details
#initialize(attributes) ⇒ Country
Returns a new instance of Country.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/restcountry/country.rb', line 31 def initialize(attributes) @name = attributes['name'] @capital = attributes['capital'] @altSpellings = attributes['altSpellings'] @relevance = attributes['relevance'] @region = attributes['region'] @subregion = attributes['subregion'] @translations = attributes['translations'] @population = attributes['population'] @latlng = attributes['latlng'] @demonym = attributes['demonym'] @area = attributes['area'] @gini = attributes['gini'] @timezones = attributes['timezones'] @borders = attributes['borders'] @nativeName = attributes['nativeName'] @callingCodes = attributes['callingCodes'] @topLevelDomain = attributes['topLevelDomain'] @alpha2Code = attributes['alpha2Code'] @alpha3Code = attributes['alpha3Code'] @currencies = attributes['currencies'] @languages = attributes['languages'] end |
Instance Attribute Details
#alpha2Code ⇒ Object (readonly)
Returns the value of attribute alpha2Code.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def alpha2Code @alpha2Code end |
#alpha3Code ⇒ Object (readonly)
Returns the value of attribute alpha3Code.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def alpha3Code @alpha3Code end |
#altSpellings ⇒ Object (readonly)
Returns the value of attribute altSpellings.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def altSpellings @altSpellings end |
#area ⇒ Object (readonly)
Returns the value of attribute area.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def area @area end |
#borders ⇒ Object (readonly)
Returns the value of attribute borders.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def borders @borders end |
#callingCodes ⇒ Object (readonly)
Returns the value of attribute callingCodes.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def callingCodes @callingCodes end |
#capital ⇒ Object (readonly)
Returns the value of attribute capital.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def capital @capital end |
#currencies ⇒ Object (readonly)
Returns the value of attribute currencies.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def currencies @currencies end |
#demonym ⇒ Object (readonly)
Returns the value of attribute demonym.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def demonym @demonym end |
#gini ⇒ Object (readonly)
Returns the value of attribute gini.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def gini @gini end |
#languages ⇒ Object (readonly)
Returns the value of attribute languages.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def languages @languages end |
#latlng ⇒ Object (readonly)
Returns the value of attribute latlng.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def latlng @latlng end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def name @name end |
#nativeName ⇒ Object (readonly)
Returns the value of attribute nativeName.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def nativeName @nativeName end |
#population ⇒ Object (readonly)
Returns the value of attribute population.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def population @population end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def region @region end |
#relevance ⇒ Object (readonly)
Returns the value of attribute relevance.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def relevance @relevance end |
#subregion ⇒ Object (readonly)
Returns the value of attribute subregion.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def subregion @subregion end |
#timezones ⇒ Object (readonly)
Returns the value of attribute timezones.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def timezones @timezones end |
#topLevelDomain ⇒ Object (readonly)
Returns the value of attribute topLevelDomain.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def topLevelDomain @topLevelDomain end |
#translations ⇒ Object (readonly)
Returns the value of attribute translations.
9 10 11 |
# File 'lib/restcountry/country.rb', line 9 def translations @translations end |
Class Method Details
.all ⇒ Object
99 100 101 102 |
# File 'lib/restcountry/country.rb', line 99 def self.all countries = get_response('all') countries.map { |attributes| new(attributes) } end |
.find(name, fulltext = false) ⇒ Object
55 56 57 58 |
# File 'lib/restcountry/country.rb', line 55 def self.find(name, fulltext = false) countries = get_response('name', name + "?fullText=#{fulltext}") new(countries.first) unless countries.empty? end |
.find_by_callingcode(callingcode) ⇒ Object
89 90 91 92 |
# File 'lib/restcountry/country.rb', line 89 def self.find_by_callingcode(callingcode) countries = get_response('callingcode', callingcode) countries.map { |attributes| new(attributes) } end |
.find_by_capital(capital) ⇒ Object
69 70 71 72 |
# File 'lib/restcountry/country.rb', line 69 def self.find_by_capital(capital) countries = get_response('capital', capital) new(countries.first) unless countries.empty? end |
.find_by_countrycode(countrycode) ⇒ Object
94 95 96 97 |
# File 'lib/restcountry/country.rb', line 94 def self.find_by_countrycode(countrycode) countries = get_response(nil, "alpha?codes=#{countrycode}") countries.map { |attributes| new(attributes) } end |
.find_by_currency(currency) ⇒ Object
64 65 66 67 |
# File 'lib/restcountry/country.rb', line 64 def self.find_by_currency(currency) countries = get_response('currency', currency) countries.map { |attributes| new(attributes) } end |
.find_by_lang(lang) ⇒ Object
84 85 86 87 |
# File 'lib/restcountry/country.rb', line 84 def self.find_by_lang(lang) countries = get_response('lang', lang) countries.map { |attributes| new(attributes) } end |
.find_by_name(name, fulltext = false) ⇒ Object
60 61 62 |
# File 'lib/restcountry/country.rb', line 60 def self.find_by_name(name, fulltext = false) find(name, fulltext) end |
.find_by_region(region) ⇒ Object
74 75 76 77 |
# File 'lib/restcountry/country.rb', line 74 def self.find_by_region(region) countries = get_response('region', region) countries.map { |attributes| new(attributes) } end |
.find_by_subregion(subregion) ⇒ Object
79 80 81 82 |
# File 'lib/restcountry/country.rb', line 79 def self.find_by_subregion(subregion) countries = get_response('subregion', subregion) countries.map { |attributes| new(attributes) } end |