Class: Pupa::VoteEvent
- Inherits:
-
Object
- Object
- Pupa::VoteEvent
- Includes:
- Concerns::Sourceable, Concerns::Timestamps, Model
- Defined in:
- lib/pupa/models/vote_event.rb
Overview
An event at which people's votes are recorded.
Instance Attribute Summary collapse
-
#counts ⇒ Object
Returns the value of attribute counts.
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#group_results ⇒ Object
Returns the value of attribute group_results.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#legislative_session_id ⇒ Object
Returns the value of attribute legislative_session_id.
-
#motion_id ⇒ Object
Returns the value of attribute motion_id.
-
#organization_id ⇒ Object
Returns the value of attribute organization_id.
-
#result ⇒ Object
Returns the value of attribute result.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
Instance Method Summary collapse
-
#add_count(option, value, group: nil) ⇒ Object
Adds a count.
-
#add_group_result(result, group: nil) ⇒ Object
Adds a group result.
-
#initialize(*args) ⇒ VoteEvent
constructor
A new instance of VoteEvent.
-
#to_s ⇒ String
Returns the vote event's identifier and organization ID.
Methods included from Concerns::Sourceable
Methods included from Model
#==, #[], #[]=, #_id=, #add_extra, #extras=, #fingerprint, #foreign_properties, #to_h, #validate!
Constructor Details
#initialize(*args) ⇒ VoteEvent
Returns a new instance of VoteEvent.
16 17 18 19 20 |
# File 'lib/pupa/models/vote_event.rb', line 16 def initialize(*args) @group_results = [] @counts = [] super end |
Instance Attribute Details
#counts ⇒ Object
Returns the value of attribute counts.
11 12 13 |
# File 'lib/pupa/models/vote_event.rb', line 11 def counts @counts end |
#end_date ⇒ Object
Returns the value of attribute end_date.
11 12 13 |
# File 'lib/pupa/models/vote_event.rb', line 11 def end_date @end_date end |
#group_results ⇒ Object
Returns the value of attribute group_results.
11 12 13 |
# File 'lib/pupa/models/vote_event.rb', line 11 def group_results @group_results end |
#identifier ⇒ Object
Returns the value of attribute identifier.
11 12 13 |
# File 'lib/pupa/models/vote_event.rb', line 11 def identifier @identifier end |
#legislative_session_id ⇒ Object
Returns the value of attribute legislative_session_id.
11 12 13 |
# File 'lib/pupa/models/vote_event.rb', line 11 def legislative_session_id @legislative_session_id end |
#motion_id ⇒ Object
Returns the value of attribute motion_id.
11 12 13 |
# File 'lib/pupa/models/vote_event.rb', line 11 def motion_id @motion_id end |
#organization_id ⇒ Object
Returns the value of attribute organization_id.
11 12 13 |
# File 'lib/pupa/models/vote_event.rb', line 11 def organization_id @organization_id end |
#result ⇒ Object
Returns the value of attribute result.
11 12 13 |
# File 'lib/pupa/models/vote_event.rb', line 11 def result @result end |
#start_date ⇒ Object
Returns the value of attribute start_date.
11 12 13 |
# File 'lib/pupa/models/vote_event.rb', line 11 def start_date @start_date end |
Instance Method Details
#add_count(option, value, group: nil) ⇒ Object
Adds a count.
62 63 64 65 66 67 68 69 70 |
# File 'lib/pupa/models/vote_event.rb', line 62 def add_count(option, value, group: nil) data = {option: option, value: value} if group data[:group] = group end if option.present? && value.present? @counts << data end end |
#add_group_result(result, group: nil) ⇒ Object
Adds a group result.
47 48 49 50 51 52 53 54 55 |
# File 'lib/pupa/models/vote_event.rb', line 47 def add_group_result(result, group: nil) data = {result: result} if group data[:group] = group end if result.present? @group_results << data end end |
#to_s ⇒ String
Returns the vote event's identifier and organization ID.
25 26 27 |
# File 'lib/pupa/models/vote_event.rb', line 25 def to_s "#{identifier} in #{organization_id}" end |