Class: Sunlight::Congress::Legislator

Inherits:
Object
  • Object
show all
Defined in:
lib/sunlight/congress/legislator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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(options)
  self.first_name = options["first_name"]
  self.last_name = options["last_name"]
  self.website = options["website"]
end

Instance Attribute Details

#first_nameObject

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_nameObject

Returns the value of attribute last_name.



10
11
12
# File 'lib/sunlight/congress/legislator.rb', line 10

def last_name
  @last_name
end

#websiteObject

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