Class: Equalshares::Result
- Inherits:
-
Object
- Object
- Equalshares::Result
- Defined in:
- lib/equalshares/result.rb
Overview
The outcome of a voting rule: the winning project ids together with outcome statistics, timing and any rule-specific notes (endowment, effective vote counts, comparison message, greedy statistics, ...).
Instance Attribute Summary collapse
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#winners ⇒ Object
readonly
Returns the value of attribute winners.
Instance Method Summary collapse
-
#effective_vote_count(project_id) ⇒ Object
Last recorded effective vote count for a project (Method of Equal Shares only), or nil for rules/projects without one.
- #endowment ⇒ Object
-
#initialize(winners:, notes:) ⇒ Result
constructor
A new instance of Result.
- #stats ⇒ Object
- #time ⇒ Object
- #to_h ⇒ Object
- #to_json ⇒ Object
- #total_cost ⇒ Object
Constructor Details
#initialize(winners:, notes:) ⇒ Result
Returns a new instance of Result.
12 13 14 15 |
# File 'lib/equalshares/result.rb', line 12 def initialize(winners:, notes:) @winners = winners @notes = notes end |
Instance Attribute Details
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
10 11 12 |
# File 'lib/equalshares/result.rb', line 10 def notes @notes end |
#winners ⇒ Object (readonly)
Returns the value of attribute winners.
10 11 12 |
# File 'lib/equalshares/result.rb', line 10 def winners @winners end |
Instance Method Details
#effective_vote_count(project_id) ⇒ Object
Last recorded effective vote count for a project (Method of Equal Shares only), or nil for rules/projects without one.
35 36 37 |
# File 'lib/equalshares/result.rb', line 35 def effective_vote_count(project_id) (notes[:effective_vote_count] || {})[project_id]&.last end |
#endowment ⇒ Object
29 30 31 |
# File 'lib/equalshares/result.rb', line 29 def endowment notes[:endowment] end |
#stats ⇒ Object
17 18 19 |
# File 'lib/equalshares/result.rb', line 17 def stats notes[:stats] end |
#time ⇒ Object
21 22 23 |
# File 'lib/equalshares/result.rb', line 21 def time notes[:time] end |
#to_h ⇒ Object
39 40 41 |
# File 'lib/equalshares/result.rb', line 39 def to_h { winners: winners, notes: notes } end |
#to_json ⇒ Object
43 44 45 |
# File 'lib/equalshares/result.rb', line 43 def to_json(*) to_h.to_json(*) end |
#total_cost ⇒ Object
25 26 27 |
# File 'lib/equalshares/result.rb', line 25 def total_cost stats[:total_cost] end |