Class: Geocodio::CongressionalDistrict
- Inherits:
-
Object
- Object
- Geocodio::CongressionalDistrict
- Defined in:
- lib/geocodio/congressional_district.rb
Instance Attribute Summary collapse
-
#congress_number ⇒ Object
readonly
Returns the value of attribute congress_number.
-
#current_legislators ⇒ Object
readonly
Returns the value of attribute current_legislators.
-
#district_number ⇒ Object
readonly
Returns the value of attribute district_number.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#proportion ⇒ Object
readonly
Returns the value of attribute proportion.
Instance Method Summary collapse
- #congress_years ⇒ Object
-
#initialize(payload = {}) ⇒ CongressionalDistrict
constructor
A new instance of CongressionalDistrict.
Constructor Details
#initialize(payload = {}) ⇒ CongressionalDistrict
Returns a new instance of CongressionalDistrict.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/geocodio/congressional_district.rb', line 11 def initialize(payload = {}) @name = payload['name'] @district_number = payload['district_number'].to_i @congress_number = payload['congress_number'].to_i @congress_years = payload['congress_years'] @proportion = payload['proportion'].to_i @current_legislators = payload['current_legislators'].map do |legislator| Legislator.new(legislator) end end |
Instance Attribute Details
#congress_number ⇒ Object (readonly)
Returns the value of attribute congress_number.
7 8 9 |
# File 'lib/geocodio/congressional_district.rb', line 7 def congress_number @congress_number end |
#current_legislators ⇒ Object (readonly)
Returns the value of attribute current_legislators.
9 10 11 |
# File 'lib/geocodio/congressional_district.rb', line 9 def current_legislators @current_legislators end |
#district_number ⇒ Object (readonly)
Returns the value of attribute district_number.
6 7 8 |
# File 'lib/geocodio/congressional_district.rb', line 6 def district_number @district_number end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/geocodio/congressional_district.rb', line 5 def name @name end |
#proportion ⇒ Object (readonly)
Returns the value of attribute proportion.
8 9 10 |
# File 'lib/geocodio/congressional_district.rb', line 8 def proportion @proportion end |
Instance Method Details
#congress_years ⇒ Object
23 24 25 26 |
# File 'lib/geocodio/congressional_district.rb', line 23 def congress_years first, last = @congress_years.split('-').map(&:to_i) first..last end |