Class: Hulse::SenateMember
- Inherits:
-
Object
- Object
- Hulse::SenateMember
- Defined in:
- lib/hulse/senate_member.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#bioguide_id ⇒ Object
readonly
Returns the value of attribute bioguide_id.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#party ⇒ Object
readonly
Returns the value of attribute party.
-
#senate_class ⇒ Object
readonly
Returns the value of attribute senate_class.
-
#state_postal ⇒ Object
readonly
Returns the value of attribute state_postal.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#website ⇒ Object
readonly
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ SenateMember
constructor
A new instance of SenateMember.
Constructor Details
#initialize(params = {}) ⇒ SenateMember
Returns a new instance of SenateMember.
7 8 9 10 11 |
# File 'lib/hulse/senate_member.rb', line 7 def initialize(params={}) params.each_pair do |k,v| instance_variable_set("@#{k}", v) end end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
4 5 6 |
# File 'lib/hulse/senate_member.rb', line 4 def address @address end |
#bioguide_id ⇒ Object (readonly)
Returns the value of attribute bioguide_id.
4 5 6 |
# File 'lib/hulse/senate_member.rb', line 4 def bioguide_id @bioguide_id end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
4 5 6 |
# File 'lib/hulse/senate_member.rb', line 4 def email @email end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
4 5 6 |
# File 'lib/hulse/senate_member.rb', line 4 def first_name @first_name end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
4 5 6 |
# File 'lib/hulse/senate_member.rb', line 4 def last_name @last_name end |
#party ⇒ Object (readonly)
Returns the value of attribute party.
4 5 6 |
# File 'lib/hulse/senate_member.rb', line 4 def party @party end |
#senate_class ⇒ Object (readonly)
Returns the value of attribute senate_class.
4 5 6 |
# File 'lib/hulse/senate_member.rb', line 4 def senate_class @senate_class end |
#state_postal ⇒ Object (readonly)
Returns the value of attribute state_postal.
4 5 6 |
# File 'lib/hulse/senate_member.rb', line 4 def state_postal @state_postal end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/hulse/senate_member.rb', line 4 def title @title end |
#website ⇒ Object (readonly)
Returns the value of attribute website.
4 5 6 |
# File 'lib/hulse/senate_member.rb', line 4 def website @website end |
Class Method Details
.create_from_xml(response) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/hulse/senate_member.rb', line 20 def self.create_from_xml(response) members = [] response['contact_information']['member'].each do |member| members << self.new(bioguide_id: member['bioguide_id'], title: member['member_full'], last_name: member['last_name'], first_name: member['first_name'], party: member['party'], state_postal: member['state'], senate_class: member['class'], address: member['address'], phone: member['phone'], email: member['email'], website: member['website'] ) end members end |
.current ⇒ Object
13 14 15 16 17 |
# File 'lib/hulse/senate_member.rb', line 13 def self.current url = "http://www.senate.gov/general/contact_information/senators_cfm.xml" response = HTTParty.get(url) self.create_from_xml(response) end |