lib/pollster/poll.rb in pollster-0.2.0 vs lib/pollster/poll.rb in pollster-0.2.1
- old
+ new
@@ -1,10 +1,10 @@
module Pollster
class Poll < Base
- attr_reader :start_date, :end_date, :method, :pollster, :url, :source, :questions
+ attr_reader :start_date, :end_date, :method, :pollster, :url, :source, :questions, :survey_houses, :sponsors
def initialize(params={})
params.each_pair do |k,v|
instance_variable_set("@#{k}", v)
end
@@ -34,9 +34,11 @@
data[:questions].each { |question| question[:subpopulations] = question[:subpopulations].map { |subpopulation| hash_keys_to_sym(subpopulation) } }
data[:questions].each { |question| question[:subpopulations].each { |subpopulation| subpopulation[:responses] = subpopulation[:responses].map { |response| hash_keys_to_sym(response) } } }
data[:questions] = data[:questions].map { |question| Pollster::Question.new(question) }
data[:start_date] = Date.parse(data[:start_date])
data[:end_date] = Date.parse(data[:end_date])
+ data[:survey_houses] = data[:survey_houses].map { |survey_house| hash_keys_to_sym(survey_house) }
+ data[:sponsors] = data[:sponsors].map { |sponsor| hash_keys_to_sym(sponsor) }
self.new(data)
end
end