Class: Hulse::HouseMember
- Inherits:
-
Object
- Object
- Hulse::HouseMember
- Defined in:
- lib/hulse/house_member.rb
Instance Attribute Summary collapse
-
#bioguide_id ⇒ Object
readonly
Returns the value of attribute bioguide_id.
-
#caucus_party ⇒ Object
readonly
Returns the value of attribute caucus_party.
-
#committees ⇒ Object
readonly
Returns the value of attribute committees.
-
#courtesy ⇒ Object
readonly
Returns the value of attribute courtesy.
-
#district_code ⇒ Object
readonly
Returns the value of attribute district_code.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#footnote ⇒ Object
readonly
Returns the value of attribute footnote.
-
#formal_name ⇒ Object
readonly
Returns the value of attribute formal_name.
-
#hometown ⇒ Object
readonly
Returns the value of attribute hometown.
-
#is_vacant ⇒ Object
readonly
Returns the value of attribute is_vacant.
-
#last_elected_date ⇒ Object
readonly
Returns the value of attribute last_elected_date.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#middle_name ⇒ Object
readonly
Returns the value of attribute middle_name.
-
#office_building ⇒ Object
readonly
Returns the value of attribute office_building.
-
#office_room ⇒ Object
readonly
Returns the value of attribute office_room.
-
#office_zip ⇒ Object
readonly
Returns the value of attribute office_zip.
-
#official_name ⇒ Object
readonly
Returns the value of attribute official_name.
-
#party ⇒ Object
readonly
Returns the value of attribute party.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#predecessor ⇒ Object
readonly
Returns the value of attribute predecessor.
-
#sort_name ⇒ Object
readonly
Returns the value of attribute sort_name.
-
#state_name ⇒ Object
readonly
Returns the value of attribute state_name.
-
#state_postal ⇒ Object
readonly
Returns the value of attribute state_postal.
-
#subcommittees ⇒ Object
readonly
Returns the value of attribute subcommittees.
-
#suffix ⇒ Object
readonly
Returns the value of attribute suffix.
-
#sworn_date ⇒ Object
readonly
Returns the value of attribute sworn_date.
-
#vacancy_date ⇒ Object
readonly
Returns the value of attribute vacancy_date.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ HouseMember
constructor
A new instance of HouseMember.
Constructor Details
#initialize(params = {}) ⇒ HouseMember
Returns a new instance of HouseMember.
9 10 11 12 13 |
# File 'lib/hulse/house_member.rb', line 9 def initialize(params={}) params.each_pair do |k,v| instance_variable_set("@#{k}", v) end end |
Instance Attribute Details
#bioguide_id ⇒ Object (readonly)
Returns the value of attribute bioguide_id.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def bioguide_id @bioguide_id end |
#caucus_party ⇒ Object (readonly)
Returns the value of attribute caucus_party.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def caucus_party @caucus_party end |
#committees ⇒ Object (readonly)
Returns the value of attribute committees.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def committees @committees end |
#courtesy ⇒ Object (readonly)
Returns the value of attribute courtesy.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def courtesy @courtesy end |
#district_code ⇒ Object (readonly)
Returns the value of attribute district_code.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def district_code @district_code end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def first_name @first_name end |
#footnote ⇒ Object (readonly)
Returns the value of attribute footnote.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def footnote @footnote end |
#formal_name ⇒ Object (readonly)
Returns the value of attribute formal_name.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def formal_name @formal_name end |
#hometown ⇒ Object (readonly)
Returns the value of attribute hometown.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def hometown @hometown end |
#is_vacant ⇒ Object (readonly)
Returns the value of attribute is_vacant.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def is_vacant @is_vacant end |
#last_elected_date ⇒ Object (readonly)
Returns the value of attribute last_elected_date.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def last_elected_date @last_elected_date end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def last_name @last_name end |
#middle_name ⇒ Object (readonly)
Returns the value of attribute middle_name.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def middle_name @middle_name end |
#office_building ⇒ Object (readonly)
Returns the value of attribute office_building.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def office_building @office_building end |
#office_room ⇒ Object (readonly)
Returns the value of attribute office_room.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def office_room @office_room end |
#office_zip ⇒ Object (readonly)
Returns the value of attribute office_zip.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def office_zip @office_zip end |
#official_name ⇒ Object (readonly)
Returns the value of attribute official_name.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def official_name @official_name end |
#party ⇒ Object (readonly)
Returns the value of attribute party.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def party @party end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def phone @phone end |
#predecessor ⇒ Object (readonly)
Returns the value of attribute predecessor.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def predecessor @predecessor end |
#sort_name ⇒ Object (readonly)
Returns the value of attribute sort_name.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def sort_name @sort_name end |
#state_name ⇒ Object (readonly)
Returns the value of attribute state_name.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def state_name @state_name end |
#state_postal ⇒ Object (readonly)
Returns the value of attribute state_postal.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def state_postal @state_postal end |
#subcommittees ⇒ Object (readonly)
Returns the value of attribute subcommittees.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def subcommittees @subcommittees end |
#suffix ⇒ Object (readonly)
Returns the value of attribute suffix.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def suffix @suffix end |
#sworn_date ⇒ Object (readonly)
Returns the value of attribute sworn_date.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def sworn_date @sworn_date end |
#vacancy_date ⇒ Object (readonly)
Returns the value of attribute vacancy_date.
4 5 6 |
# File 'lib/hulse/house_member.rb', line 4 def vacancy_date @vacancy_date end |
Class Method Details
.create_from_xml(response) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/hulse/house_member.rb', line 22 def self.create_from_xml(response) members = [] response['MemberData']['members']['member'].each do |member| if member['member_info']['elected_date']['date'] == '' footnote = member['member_info']['footnote'] predecessor = member['predecessor_info'] vacancy_date = Date.parse(member['predecessor_info']['pred_vacate_date']['date']) vacant = true else footnote, predecessor, vacancy_date = nil vacant = false end members << self.new(bioguide_id: member['member_info']['bioguideID'], sort_name: member['member_info']['sort_name'], last_name: member['member_info']['lastname'], first_name: member['member_info']['firstname'], middle_name: member['member_info']['middlename'], suffix: member['member_info']['suffix'], courtesy: member['member_info']['courtesy'], official_name: member['member_info']['official_name'], formal_name: member['member_info']['formal_name'], party: member['member_info']['party'], caucus_party: member['member_info']['caucus'], state_postal: member['member_info']['state']['postal_code'], state_name: member['member_info']['state']['state_fullname'], district: member['member_info']['district'], district_code: member['statedistrict'], hometown: member['member_info']['townname'], office_building: member['member_info']['office_building'], office_room: member['member_info']['office_room'], office_zip: member['member_info']['office_zip']+'-'+member['member_info']['office_zip_suffix'], phone: member['member_info']['phone'], last_elected_date: begin Date.parse(member['member_info']['elected_date']['date']) rescue nil end, sworn_date: begin Date.parse(member['member_info']['sworn_date']['date']) rescue nil end, committees: member['committee_assignments']['committee'], subcommittees: member['committee_assignments']['subcommittee'], is_vacant: vacant, footnote: footnote, predecessor: predecessor, vacancy_date: vacancy_date ) end members end |
.current ⇒ Object
15 16 17 18 19 |
# File 'lib/hulse/house_member.rb', line 15 def self.current url = "http://clerk.house.gov/xml/lists/MemberData.xml" response = HTTParty.get(url) self.create_from_xml(response) end |