Class: GovKit::OpenCongress::Person
- Inherits:
-
OpenCongressObject
- Object
- OpenCongressObject
- GovKit::OpenCongress::Person
- Defined in:
- lib/gov_kit/open_congress/person.rb
Instance Attribute Summary collapse
-
#abstains_percentage ⇒ Object
Returns the value of attribute abstains_percentage.
-
#bioguideid ⇒ Object
Returns the value of attribute bioguideid.
-
#birthday ⇒ Object
Returns the value of attribute birthday.
-
#district ⇒ Object
Returns the value of attribute district.
-
#email ⇒ Object
Returns the value of attribute email.
-
#firstname ⇒ Object
Returns the value of attribute firstname.
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lastname ⇒ Object
Returns the value of attribute lastname.
-
#metavid_id ⇒ Object
Returns the value of attribute metavid_id.
-
#middlename ⇒ Object
Returns the value of attribute middlename.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nickname ⇒ Object
Returns the value of attribute nickname.
-
#oc_user_comments ⇒ Object
Returns the value of attribute oc_user_comments.
-
#oc_users_tracking ⇒ Object
Returns the value of attribute oc_users_tracking.
-
#osid ⇒ Object
Returns the value of attribute osid.
-
#party ⇒ Object
Returns the value of attribute party.
-
#person_stats ⇒ Object
Returns the value of attribute person_stats.
-
#recent_blogs ⇒ Object
Returns the value of attribute recent_blogs.
-
#recent_news ⇒ Object
Returns the value of attribute recent_news.
-
#religion ⇒ Object
Returns the value of attribute religion.
-
#state ⇒ Object
Returns the value of attribute state.
-
#title ⇒ Object
Returns the value of attribute title.
-
#unaccented_name ⇒ Object
Returns the value of attribute unaccented_name.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user_approval ⇒ Object
Returns the value of attribute user_approval.
-
#with_party_percentage ⇒ Object
Returns the value of attribute with_party_percentage.
-
#youtube_id ⇒ Object
Returns the value of attribute youtube_id.
Class Method Summary collapse
- .compare(person1, person2) ⇒ Object
- .find(params) ⇒ Object
- .most_blogged_representatives_this_week ⇒ Object
- .most_blogged_senators_this_week ⇒ Object
- .parse_results(result) ⇒ Object
- .representatives_most_in_the_news_this_week ⇒ Object
- .senators_most_in_the_news_this_week ⇒ Object
Instance Method Summary collapse
-
#initialize(params) ⇒ Person
constructor
A new instance of Person.
- #opencongress_users_opposing_person_are_also ⇒ Object
- #opencongress_users_supporting_person_are_also ⇒ Object
Methods inherited from OpenCongressObject
construct_url, hash2get, make_call, parse_supporting_results
Constructor Details
Instance Attribute Details
#abstains_percentage ⇒ Object
Returns the value of attribute abstains_percentage.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def abstains_percentage @abstains_percentage end |
#bioguideid ⇒ Object
Returns the value of attribute bioguideid.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def bioguideid @bioguideid end |
#birthday ⇒ Object
Returns the value of attribute birthday.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def birthday @birthday end |
#district ⇒ Object
Returns the value of attribute district.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def district @district end |
#email ⇒ Object
Returns the value of attribute email.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def email @email end |
#firstname ⇒ Object
Returns the value of attribute firstname.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def firstname @firstname end |
#gender ⇒ Object
Returns the value of attribute gender.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def gender @gender end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def id @id end |
#lastname ⇒ Object
Returns the value of attribute lastname.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def lastname @lastname end |
#metavid_id ⇒ Object
Returns the value of attribute metavid_id.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def @metavid_id end |
#middlename ⇒ Object
Returns the value of attribute middlename.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def middlename @middlename end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def name @name end |
#nickname ⇒ Object
Returns the value of attribute nickname.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def nickname @nickname end |
#oc_user_comments ⇒ Object
Returns the value of attribute oc_user_comments.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def oc_user_comments @oc_user_comments end |
#oc_users_tracking ⇒ Object
Returns the value of attribute oc_users_tracking.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def oc_users_tracking @oc_users_tracking end |
#osid ⇒ Object
Returns the value of attribute osid.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def osid @osid end |
#party ⇒ Object
Returns the value of attribute party.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def party @party end |
#person_stats ⇒ Object
Returns the value of attribute person_stats.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def person_stats @person_stats end |
#recent_blogs ⇒ Object
Returns the value of attribute recent_blogs.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def recent_blogs @recent_blogs end |
#recent_news ⇒ Object
Returns the value of attribute recent_news.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def recent_news @recent_news end |
#religion ⇒ Object
Returns the value of attribute religion.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def religion @religion end |
#state ⇒ Object
Returns the value of attribute state.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def state @state end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def title @title end |
#unaccented_name ⇒ Object
Returns the value of attribute unaccented_name.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def unaccented_name @unaccented_name end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def url @url end |
#user_approval ⇒ Object
Returns the value of attribute user_approval.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def user_approval @user_approval end |
#with_party_percentage ⇒ Object
Returns the value of attribute with_party_percentage.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def with_party_percentage @with_party_percentage end |
#youtube_id ⇒ Object
Returns the value of attribute youtube_id.
6 7 8 |
# File 'lib/gov_kit/open_congress/person.rb', line 6 def youtube_id @youtube_id end |
Class Method Details
.compare(person1, person2) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/gov_kit/open_congress/person.rb', line 27 def self.compare(person1, person2) url = "#{GovKit::configuration.opencongress_base_url}person/compare.json?person1=#{person1.id}&person2=#{person2.id}" if (result = make_call(url)) comparison = VotingComparison.new(result["comparison"]) else nil end end |
.find(params) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gov_kit/open_congress/person.rb', line 15 def self.find(params) url = construct_url("people", params) if (result = make_call(url)) people = parse_results(result) return people else nil end end |
.most_blogged_representatives_this_week ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/gov_kit/open_congress/person.rb', line 73 def self.most_blogged_representatives_this_week url = construct_url("most_blogged_representatives_this_week", {}) if (result = make_call(url)) people = parse_results(result) return people else nil end end |
.most_blogged_senators_this_week ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/gov_kit/open_congress/person.rb', line 61 def self.most_blogged_senators_this_week url = construct_url("most_blogged_senators_this_week", {}) if (result = make_call(url)) people = parse_results(result) return people else nil end end |
.parse_results(result) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/gov_kit/open_congress/person.rb', line 105 def self.parse_results(result) people = [] if Hash === result result["people"].each do |person| person = person['person'] these_recent_blogs = person["recent_blogs"] blogs = [] these_recent_blogs.each do |trb| blogs << BlogPost.new(trb) end person["recent_blogs"] = blogs these_recent_news = person["recent_news"] news = [] these_recent_news.each do |trb| news << NewsPost.new(trb) end person["person_stats"] = PersonStat.new(person["person_stats"]) if person["person_stats"] person["recent_news"] = news people << Person.new(person) end end people end |
.representatives_most_in_the_news_this_week ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gov_kit/open_congress/person.rb', line 49 def self.representatives_most_in_the_news_this_week url = construct_url("representatives_most_in_the_news_this_week", {}) if (result = make_call(url)) people = parse_results(result) return people else nil end end |
.senators_most_in_the_news_this_week ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gov_kit/open_congress/person.rb', line 37 def self.senators_most_in_the_news_this_week url = construct_url("senators_most_in_the_news_this_week", {}) if (result = make_call(url)) people = parse_results(result) return people else nil end end |
Instance Method Details
#opencongress_users_opposing_person_are_also ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/gov_kit/open_congress/person.rb', line 95 def opencongress_users_opposing_person_are_also url = Person.construct_url("opencongress_users_opposing_person_are_also/#{id}", {}) if (result = Person.make_call(url)) people = Person.parse_supporting_results(result) return people else nil end end |
#opencongress_users_supporting_person_are_also ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/gov_kit/open_congress/person.rb', line 85 def opencongress_users_supporting_person_are_also url = Person.construct_url("opencongress_users_supporting_person_are_also/#{id}", {}) if (result = Person.make_call(url)) people = Person.parse_supporting_results(result) return people else nil end end |