Class: GovKit::OpenCongress::Person

Inherits:
OpenCongressObject show all
Defined in:
lib/gov_kit/open_congress/person.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OpenCongressObject

construct_url, hash2get, make_call, parse_supporting_results

Constructor Details

#initialize(params) ⇒ Person

Returns a new instance of Person.



11
12
13
# File 'lib/gov_kit/open_congress/person.rb', line 11

def initialize(params)
  super Person, params
end

Instance Attribute Details

#abstains_percentageObject

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

#bioguideidObject

Returns the value of attribute bioguideid.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def bioguideid
  @bioguideid
end

#birthdayObject

Returns the value of attribute birthday.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def birthday
  @birthday
end

#districtObject

Returns the value of attribute district.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def district
  @district
end

#emailObject

Returns the value of attribute email.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def email
  @email
end

#firstnameObject

Returns the value of attribute firstname.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def firstname
  @firstname
end

#genderObject

Returns the value of attribute gender.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def gender
  @gender
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def id
  @id
end

#lastnameObject

Returns the value of attribute lastname.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def lastname
  @lastname
end

#metavid_idObject

Returns the value of attribute metavid_id.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def metavid_id
  @metavid_id
end

#middlenameObject

Returns the value of attribute middlename.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def middlename
  @middlename
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def name
  @name
end

#nicknameObject

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_commentsObject

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_trackingObject

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

#osidObject

Returns the value of attribute osid.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def osid
  @osid
end

#partyObject

Returns the value of attribute party.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def party
  @party
end

#person_statsObject

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_blogsObject

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_newsObject

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

#religionObject

Returns the value of attribute religion.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def religion
  @religion
end

#stateObject

Returns the value of attribute state.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def state
  @state
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def title
  @title
end

#unaccented_nameObject

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

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/gov_kit/open_congress/person.rb', line 6

def url
  @url
end

#user_approvalObject

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_percentageObject

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_idObject

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_weekObject



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_weekObject



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
# File 'lib/gov_kit/open_congress/person.rb', line 105

def self.parse_results(result)

    people = []
    result["people"].each do |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      
  
    people
      
end

.representatives_most_in_the_news_this_weekObject



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_weekObject



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_alsoObject



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_alsoObject



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