Class: Pollster::Poll
Constant Summary
Constants inherited from Base
Base::API_BASE, Base::API_SERVER
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#pollster ⇒ Object
readonly
Returns the value of attribute pollster.
-
#questions ⇒ Object
readonly
Returns the value of attribute questions.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#sponsors ⇒ Object
readonly
Returns the value of attribute sponsors.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#survey_houses ⇒ Object
readonly
Returns the value of attribute survey_houses.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.all(params = {}) ⇒ Object
Get a list of all polls.
-
.where(params = {}) ⇒ Object
Get a list of polls based on the given parameters.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Poll
constructor
A new instance of Poll.
Constructor Details
#initialize(params = {}) ⇒ Poll
Returns a new instance of Poll.
7 8 9 10 11 |
# File 'lib/pollster/poll.rb', line 7 def initialize(params={}) params.each_pair do |k,v| instance_variable_set("@#{k}", v) end end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
5 6 7 |
# File 'lib/pollster/poll.rb', line 5 def end_date @end_date end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
5 6 7 |
# File 'lib/pollster/poll.rb', line 5 def method @method end |
#pollster ⇒ Object (readonly)
Returns the value of attribute pollster.
5 6 7 |
# File 'lib/pollster/poll.rb', line 5 def pollster @pollster end |
#questions ⇒ Object (readonly)
Returns the value of attribute questions.
5 6 7 |
# File 'lib/pollster/poll.rb', line 5 def questions @questions end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/pollster/poll.rb', line 5 def source @source end |
#sponsors ⇒ Object (readonly)
Returns the value of attribute sponsors.
5 6 7 |
# File 'lib/pollster/poll.rb', line 5 def sponsors @sponsors end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
5 6 7 |
# File 'lib/pollster/poll.rb', line 5 def start_date @start_date end |
#survey_houses ⇒ Object (readonly)
Returns the value of attribute survey_houses.
5 6 7 |
# File 'lib/pollster/poll.rb', line 5 def survey_houses @survey_houses end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/pollster/poll.rb', line 5 def url @url end |
Class Method Details
.all(params = {}) ⇒ Object
Get a list of all polls. Polls are listed in pages of 10.
15 16 17 18 |
# File 'lib/pollster/poll.rb', line 15 def self.all(params={}) page = params[:page] || 1 invoke('polls', {:page => page}).map { |poll| self.create(poll) } end |
.where(params = {}) ⇒ Object
Get a list of polls based on the given parameters. See API documentation for acceptable parameters.
22 23 24 25 26 27 |
# File 'lib/pollster/poll.rb', line 22 def self.where(params={}) if params.empty? raise "A search parameter is required" end invoke('polls', params).map { |poll| self.create(poll) } end |