Class: Poll
- Inherits:
-
Object
- Object
- Poll
- Defined in:
- lib/objects/poll.rb
Overview
This object contains information about a poll.
Instance Method Summary collapse
-
#anonymous? ⇒ Boolean
True, if the poll is anonymous.
-
#close_date ⇒ Object
Optional.
Point in time (Unix timestamp) when the poll will be automatically closed. -
#closed? ⇒ Boolean
True, if the poll is closed.
-
#correct_option_id ⇒ Object
Optional
. -
#explanation ⇒ Object
Optional.
Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters. -
#explanation_entities ⇒ Object
Optional.
Special entities like usernames, URLs, bot commands, etc. -
#id ⇒ Object
Unique poll identifier.
-
#initialize(poll) ⇒ Poll
constructor
:nodoc:.
-
#open_period ⇒ Object
Optional.
Amount of time in seconds the poll will be active after creation. -
#options ⇒ Object
Returns array of PollOption s.
-
#question ⇒ Object
Poll question, 1-255 characters.
-
#total_voter_count ⇒ Object
Total number of users that voted in the poll.
-
#type ⇒ Object
Poll type, currently can be “regular” or “quiz”.
Constructor Details
#initialize(poll) ⇒ Poll
:nodoc:
9 10 11 12 |
# File 'lib/objects/poll.rb', line 9 def initialize(poll) # :nodoc: @poll = poll freeze end |
Instance Method Details
#anonymous? ⇒ Boolean
True, if the poll is anonymous.
49 50 51 |
# File 'lib/objects/poll.rb', line 49 def anonymous? @poll.is_anonymous end |
#close_date ⇒ Object
Optional.
Point in time (Unix timestamp) when the poll will be automatically closed.
94 95 96 |
# File 'lib/objects/poll.rb', line 94 def close_date @poll.close_date end |
#closed? ⇒ Boolean
True, if the poll is closed.
44 45 46 |
# File 'lib/objects/poll.rb', line 44 def closed? @poll.is_closed end |
#correct_option_id ⇒ Object
Optional
. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.
61 62 63 |
# File 'lib/objects/poll.rb', line 61 def correct_option_id @poll.correct_option_id end |
#explanation ⇒ Object
Optional.
Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters.
67 68 69 |
# File 'lib/objects/poll.rb', line 67 def explanation @poll.explanation end |
#explanation_entities ⇒ Object
Optional.
Special entities like usernames, URLs, bot commands, etc. that appear in the explanation.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/objects/poll.rb', line 73 def explanation_entities data = @poll.explanation_entities unless data return false end explanations = [] data.each do |exp| explanations << MessageEntity.new(exp) end explanations end |
#id ⇒ Object
Unique poll identifier.
15 16 17 |
# File 'lib/objects/poll.rb', line 15 def id @poll.id end |
#open_period ⇒ Object
Optional.
Amount of time in seconds the poll will be active after creation.
88 89 90 |
# File 'lib/objects/poll.rb', line 88 def open_period @poll.open_period end |
#options ⇒ Object
Returns array of PollOption s. else false is returned.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/objects/poll.rb', line 25 def opt = @poll. unless opt return false end = [] opt.each do |o| << PollOption.new(o) end end |
#question ⇒ Object
Poll question, 1-255 characters.
20 21 22 |
# File 'lib/objects/poll.rb', line 20 def question @poll.question end |
#total_voter_count ⇒ Object
Total number of users that voted in the poll.
39 40 41 |
# File 'lib/objects/poll.rb', line 39 def total_voter_count @poll.total_voter_count end |
#type ⇒ Object
Poll type, currently can be “regular” or “quiz”
54 55 56 |
# File 'lib/objects/poll.rb', line 54 def type @poll.type end |