Class: Sunlight::Congress::District
- Inherits:
-
CongressApi
- Object
- CongressApi
- Sunlight::Congress::District
- Defined in:
- lib/sunlight/congress/district.rb
Instance Attribute Summary collapse
-
#district ⇒ Object
Returns the value of attribute district.
-
#state ⇒ Object
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ District
constructor
A new instance of District.
Methods inherited from CongressApi
create_from_response, encode_uri
Constructor Details
#initialize(options = {}) ⇒ District
Returns a new instance of District.
7 8 9 10 11 |
# File 'lib/sunlight/congress/district.rb', line 7 def initialize( = {}) .each do |attribute, value| instance_variable_set("@#{attribute}", value) end end |
Instance Attribute Details
#district ⇒ Object
Returns the value of attribute district.
5 6 7 |
# File 'lib/sunlight/congress/district.rb', line 5 def district @district end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/sunlight/congress/district.rb', line 5 def state @state end |
Class Method Details
.locate(options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sunlight/congress/district.rb', line 14 def locate() if .is_a?(String) || [:address] coords = Geocoder.coordinates() response = Net::HTTP.get_response(locate_uri(latitude: coords[0], longitude: coords[1])) else response = Net::HTTP.get_response(locate_uri()) end create_from_response(response) end |
.locate_uri(options = {}) ⇒ Object
25 26 27 |
# File 'lib/sunlight/congress/district.rb', line 25 def locate_uri( = {}) encode_uri('legislators/locate', ) end |