Class: Poll

Inherits:
Object
  • Object
show all
Defined in:
lib/objects/poll.rb

Overview

This object contains information about a poll.

Instance Method Summary collapse

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.

Returns:

  • (Boolean)


49
50
51
# File 'lib/objects/poll.rb', line 49

def anonymous?
  @poll.is_anonymous
end

#close_dateObject

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.

Returns:

  • (Boolean)


44
45
46
# File 'lib/objects/poll.rb', line 44

def closed?
  @poll.is_closed
end

#correct_option_idObject

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

#explanationObject

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_entitiesObject

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

#idObject

Unique poll identifier.



15
16
17
# File 'lib/objects/poll.rb', line 15

def id
  @poll.id
end

#open_periodObject

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

#optionsObject

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 options
  opt = @poll.options
  unless opt
    return false
  end

  poll_options = []
  opt.each do |o|
    poll_options << PollOption.new(o)
  end
  poll_options
end

#questionObject

Poll question, 1-255 characters.



20
21
22
# File 'lib/objects/poll.rb', line 20

def question
  @poll.question
end

#total_voter_countObject

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

#typeObject

Poll type, currently can be “regular” or “quiz”



54
55
56
# File 'lib/objects/poll.rb', line 54

def type
  @poll.type
end