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) ⇒ Object
- .find_by_callingcode(callingcode) ⇒ Object
- .find_by_capital(capital) ⇒ Object
- .find_by_currency(currency) ⇒ Object
- .find_by_lang(lang) ⇒ Object
- .find_by_name(name) ⇒ 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.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/restcountry/country.rb', line 30 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.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def alpha2Code @alpha2Code end |
#alpha3Code ⇒ Object (readonly)
Returns the value of attribute alpha3Code.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def alpha3Code @alpha3Code end |
#altSpellings ⇒ Object (readonly)
Returns the value of attribute altSpellings.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def altSpellings @altSpellings end |
#area ⇒ Object (readonly)
Returns the value of attribute area.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def area @area end |
#borders ⇒ Object (readonly)
Returns the value of attribute borders.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def borders @borders end |
#callingCodes ⇒ Object (readonly)
Returns the value of attribute callingCodes.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def callingCodes @callingCodes end |
#capital ⇒ Object (readonly)
Returns the value of attribute capital.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def capital @capital end |
#currencies ⇒ Object (readonly)
Returns the value of attribute currencies.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def currencies @currencies end |
#demonym ⇒ Object (readonly)
Returns the value of attribute demonym.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def demonym @demonym end |
#gini ⇒ Object (readonly)
Returns the value of attribute gini.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def gini @gini end |
#languages ⇒ Object (readonly)
Returns the value of attribute languages.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def languages @languages end |
#latlng ⇒ Object (readonly)
Returns the value of attribute latlng.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def latlng @latlng end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def name @name end |
#nativeName ⇒ Object (readonly)
Returns the value of attribute nativeName.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def nativeName @nativeName end |
#population ⇒ Object (readonly)
Returns the value of attribute population.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def population @population end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def region @region end |
#relevance ⇒ Object (readonly)
Returns the value of attribute relevance.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def relevance @relevance end |
#subregion ⇒ Object (readonly)
Returns the value of attribute subregion.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def subregion @subregion end |
#timezones ⇒ Object (readonly)
Returns the value of attribute timezones.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def timezones @timezones end |
#topLevelDomain ⇒ Object (readonly)
Returns the value of attribute topLevelDomain.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def topLevelDomain @topLevelDomain end |
#translations ⇒ Object (readonly)
Returns the value of attribute translations.
8 9 10 |
# File 'lib/restcountry/country.rb', line 8 def translations @translations end |
Class Method Details
.all ⇒ Object
93 94 95 96 |
# File 'lib/restcountry/country.rb', line 93 def self.all countries = get_response('all') countries.map { |attributes| new(attributes) } end |
.find(name) ⇒ Object
54 55 56 57 |
# File 'lib/restcountry/country.rb', line 54 def self.find(name) countries = get_response('name', name) new(countries.first) unless countries.empty? end |
.find_by_callingcode(callingcode) ⇒ Object
88 89 90 91 |
# File 'lib/restcountry/country.rb', line 88 def self.find_by_callingcode(callingcode) countries = get_response('callingcode', callingcode) countries.map { |attributes| new(attributes) } end |
.find_by_capital(capital) ⇒ Object
68 69 70 71 |
# File 'lib/restcountry/country.rb', line 68 def self.find_by_capital(capital) countries = get_response('capital', capital) new(countries.first) unless countries.empty? end |
.find_by_currency(currency) ⇒ Object
63 64 65 66 |
# File 'lib/restcountry/country.rb', line 63 def self.find_by_currency(currency) countries = get_response('currency', currency) countries.map { |attributes| new(attributes) } end |
.find_by_lang(lang) ⇒ Object
83 84 85 86 |
# File 'lib/restcountry/country.rb', line 83 def self.find_by_lang(lang) countries = get_response('lang', lang) countries.map { |attributes| new(attributes) } end |
.find_by_name(name) ⇒ Object
59 60 61 |
# File 'lib/restcountry/country.rb', line 59 def self.find_by_name(name) find(name) end |
.find_by_region(region) ⇒ Object
73 74 75 76 |
# File 'lib/restcountry/country.rb', line 73 def self.find_by_region(region) countries = get_response('region', region) countries.map { |attributes| new(attributes) } end |
.find_by_subregion(subregion) ⇒ Object
78 79 80 81 |
# File 'lib/restcountry/country.rb', line 78 def self.find_by_subregion(subregion) countries = get_response('subregion', subregion) countries.map { |attributes| new(attributes) } end |