Class: Sunlight::Congress::Legislator
- Inherits:
-
Object
- Object
- Sunlight::Congress::Legislator
- Defined in:
- lib/sunlight/congress/legislator.rb
Instance Attribute Summary collapse
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Legislator
constructor
A new instance of Legislator.
Constructor Details
#initialize(options) ⇒ Legislator
Returns a new instance of Legislator.
12 13 14 15 16 |
# File 'lib/sunlight/congress/legislator.rb', line 12 def initialize() self.first_name = ["first_name"] self.last_name = ["last_name"] self.website = ["website"] end |
Instance Attribute Details
#first_name ⇒ Object
Returns the value of attribute first_name.
10 11 12 |
# File 'lib/sunlight/congress/legislator.rb', line 10 def first_name @first_name end |
#last_name ⇒ Object
Returns the value of attribute last_name.
10 11 12 |
# File 'lib/sunlight/congress/legislator.rb', line 10 def last_name @last_name end |
#website ⇒ Object
Returns the value of attribute website.
10 11 12 |
# File 'lib/sunlight/congress/legislator.rb', line 10 def website @website end |
Class Method Details
.by_zipcode(zipcode) ⇒ Object
18 19 20 21 22 |
# File 'lib/sunlight/congress/legislator.rb', line 18 def self.by_zipcode(zipcode) uri = URI("http://congress.api.sunlightfoundation.com/legislators/locate?zip=#{zipcode}&apikey=#{Sunlight::Congress.api_key}") JSON.load(Net::HTTP.get(uri))["results"].collect{|json| new(json) } end |