Class: Everypolitician::Country

Inherits:
Entity
  • Object
show all
Defined in:
lib/everypolitician.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#initialize, #process_data

Constructor Details

This class inherits a constructor from Everypolitician::Entity

Class Method Details

.find(slug) ⇒ Object



48
49
50
51
52
# File 'lib/everypolitician.rb', line 48

def self.find(slug)
  country = CountriesJson.new.find { |c| c[:slug] == slug }
  fail Error, "Unknown country slug: #{slug}" if country.nil?
  new(country)
end

Instance Method Details

#legislature(slug) ⇒ Object



54
55
56
57
58
# File 'lib/everypolitician.rb', line 54

def legislature(slug)
  legislature = legislatures.find { |l| l[:slug] == slug }
  fail Error, "Unknown legislature slug: #{slug}" if legislature.nil?
  Legislature.new(legislature)
end