class ListOfCountries::Country
Attributes
demonyms[R]
languages[R]
name[R]
region[R]
subregion[R]
Public Class Methods
new(data)
click to toggle source
# File lib/list_of_countries/country.rb, line 14 def initialize(data) @name = Name.new(data.fetch("name")) @demonyms = Demonyms.new(fetch_demonyms(data)) @languages = data.fetch("languages").values @region = data.fetch("region") @subregion = data.fetch("subregion") end
Private Instance Methods
fetch_demonyms(data)
click to toggle source
# File lib/list_of_countries/country.rb, line 24 def fetch_demonyms(data) demonym = data["demonym"] if demonym return { "eng" => { "f" => demonym, "m" => demonym, }, } end demonyms = data["demonyms"] if demonyms return demonyms end raise KeyError, %q{keys not found: "demonym" or "demonyms"} end