lib/opencongress/person.rb in opencongress-opencongress-ruby-0.0.4 vs lib/opencongress/person.rb in opencongress-opencongress-ruby-0.1.2

- old
+ new

@@ -1,19 +1,19 @@ module OpenCongress - class Person < OpenCongressObject + class OCPerson < OpenCongressObject attr_accessor :firstname, :lastname, :bioguideid, :birthday, :district, :email, :gender, :id, :metavid_id, :middlename, :name, :nickname, :osid, :party, :religion, :state, :title, :unaccented_name, :url, :user_approval, :youtube_id, :oc_user_comments, :oc_users_tracking, :abstains_percentage, :with_party_percentage, :recent_news, :recent_blogs, :person_stats def initialize(params) params.each do |key, value| - instance_variable_set("@#{key}", value) if Person.instance_methods.include? key + instance_variable_set("@#{key}", value) if OCPerson.instance_methods.include? key end end def self.all_where(params) @@ -26,13 +26,13 @@ end end def self.compare(person1, person2) - url = "http://192.168.1.7:3000/person/compare.json?person1=#{person1.id}&person2=#{person2.id}" + url = "#{OC_BASE}person/compare.json?person1=#{person1.id}&person2=#{person2.id}" if (result = make_call(url)) - comparison = VotingComparison.new(result["comparison"]) + comparison = OCVotingComparison.new(result["comparison"]) else nil end end @@ -84,25 +84,23 @@ end end def opencongress_users_supporting_person_are_also - url = Person.construct_url("opencongress_users_supporting_person_are_also/#{id}", {}) - if (result = Person.make_call(url)) - puts result.to_yaml - people = Person.parse_supporting_results(result) + url = OCPerson.construct_url("opencongress_users_supporting_person_are_also/#{id}", {}) + if (result = OCPerson.make_call(url)) + people = OCPerson.parse_supporting_results(result) return people else nil end end def opencongress_users_opposing_person_are_also - url = Person.construct_url("opencongress_users_opposing_person_are_also/#{id}", {}) - if (result = Person.make_call(url)) - puts result.to_yaml - people = Person.parse_supporting_results(result) + url = OCPerson.construct_url("opencongress_users_opposing_person_are_also/#{id}", {}) + if (result = OCPerson.make_call(url)) + people = OCPerson.parse_supporting_results(result) return people else nil end end @@ -117,33 +115,33 @@ result.each do |person| these_recent_blogs = person["recent_blogs"] blogs = [] these_recent_blogs.each do |trb| - blogs << BlogPost.new(trb) + blogs << OCBlogPost.new(trb) end person["recent_blogs"] = blogs these_recent_news = person["recent_news"] news = [] these_recent_news.each do |trb| - news << NewsPost.new(trb) + news << OCNewsPost.new(trb) end - person["person_stats"] = PersonStat.new(person["person_stats"]) if person["person_stats"] + person["person_stats"] = OCPersonStat.new(person["person_stats"]) if person["person_stats"] person["recent_news"] = news - people << Person.new(person) + people << OCPerson.new(person) end people end end -end \ No newline at end of file +end