Class: BBBEvents::Poll
- Inherits:
-
Object
- Object
- BBBEvents::Poll
- Defined in:
- lib/bbbevents/poll.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#options ⇒ Object
Returns the value of attribute options.
-
#published ⇒ Object
Returns the value of attribute published.
-
#question ⇒ Object
Returns the value of attribute question.
-
#start ⇒ Object
Returns the value of attribute start.
-
#type ⇒ Object
Returns the value of attribute type.
-
#votes ⇒ Object
Returns the value of attribute votes.
Instance Method Summary collapse
-
#initialize(poll_event) ⇒ Poll
constructor
A new instance of Poll.
- #published? ⇒ Boolean
- #to_h ⇒ Object (also: #as_json)
- #to_json ⇒ Object
Constructor Details
#initialize(poll_event) ⇒ Poll
Returns a new instance of Poll.
5 6 7 8 9 10 11 12 |
# File 'lib/bbbevents/poll.rb', line 5 def initialize(poll_event) @id = poll_event["pollId"] @type = poll_event["type"] @question = poll_event["question"].nil? ? "" : "#{poll_event['question']}" @published = false @options = JSON.parse(poll_event["answers"]).map { |opt| opt["key"] } @votes = {} end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/bbbevents/poll.rb', line 3 def id @id end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/bbbevents/poll.rb', line 3 def @options end |
#published ⇒ Object
Returns the value of attribute published.
3 4 5 |
# File 'lib/bbbevents/poll.rb', line 3 def published @published end |
#question ⇒ Object
Returns the value of attribute question.
3 4 5 |
# File 'lib/bbbevents/poll.rb', line 3 def question @question end |
#start ⇒ Object
Returns the value of attribute start.
3 4 5 |
# File 'lib/bbbevents/poll.rb', line 3 def start @start end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/bbbevents/poll.rb', line 3 def type @type end |
#votes ⇒ Object
Returns the value of attribute votes.
3 4 5 |
# File 'lib/bbbevents/poll.rb', line 3 def votes @votes end |
Instance Method Details
#published? ⇒ Boolean
14 15 16 |
# File 'lib/bbbevents/poll.rb', line 14 def published? @published end |
#to_h ⇒ Object Also known as: as_json
18 19 20 21 22 |
# File 'lib/bbbevents/poll.rb', line 18 def to_h hash = {} instance_variables.each { |var| hash[var[1..-1]] = instance_variable_get(var) } hash end |
#to_json ⇒ Object
25 26 27 |
# File 'lib/bbbevents/poll.rb', line 25 def to_json JSON.generate(as_json) end |