Class: ClearElection::Election::Contest
- Inherits:
-
Object
- Object
- ClearElection::Election::Contest
- Defined in:
- lib/clear-election-sdk/election.rb
Instance Attribute Summary collapse
-
#candidates ⇒ Object
readonly
Returns the value of attribute candidates.
-
#contestId ⇒ Object
readonly
Returns the value of attribute contestId.
-
#multiplicity ⇒ Object
readonly
Returns the value of attribute multiplicity.
-
#ranked ⇒ Object
readonly
Returns the value of attribute ranked.
-
#writeIn ⇒ Object
readonly
Returns the value of attribute writeIn.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(contestId:, name:, ranked: nil, multiplicity: nil, writeIn: nil, candidates:) ⇒ Contest
constructor
A new instance of Contest.
Constructor Details
#initialize(contestId:, name:, ranked: nil, multiplicity: nil, writeIn: nil, candidates:) ⇒ Contest
Returns a new instance of Contest.
94 95 96 97 98 99 100 101 |
# File 'lib/clear-election-sdk/election.rb', line 94 def initialize(contestId:, name:, ranked: nil, multiplicity: nil, writeIn: nil, candidates:) @contestId = contestId @name = name @ranked = ranked || false @multiplicity = multiplicity || 1 @writeIn = writeIn || false @candidates = candidates end |
Instance Attribute Details
#candidates ⇒ Object (readonly)
Returns the value of attribute candidates.
92 93 94 |
# File 'lib/clear-election-sdk/election.rb', line 92 def candidates @candidates end |
#contestId ⇒ Object (readonly)
Returns the value of attribute contestId.
92 93 94 |
# File 'lib/clear-election-sdk/election.rb', line 92 def contestId @contestId end |
#multiplicity ⇒ Object (readonly)
Returns the value of attribute multiplicity.
92 93 94 |
# File 'lib/clear-election-sdk/election.rb', line 92 def multiplicity @multiplicity end |
#ranked ⇒ Object (readonly)
Returns the value of attribute ranked.
92 93 94 |
# File 'lib/clear-election-sdk/election.rb', line 92 def ranked @ranked end |
#writeIn ⇒ Object (readonly)
Returns the value of attribute writeIn.
92 93 94 |
# File 'lib/clear-election-sdk/election.rb', line 92 def writeIn @writeIn end |
Class Method Details
.from_json(data) ⇒ Object
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/clear-election-sdk/election.rb', line 103 def self.from_json(data) self.new( contestId: data["contestId"], name: data["name"], ranked: data["ranked"], multiplicity: data["multiplicity"], writeIn: data["writeIn"], candidates: data["candidates"].map {|data| Candidate.from_json(data)} ) end |
Instance Method Details
#as_json ⇒ Object
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/clear-election-sdk/election.rb', line 114 def as_json { "contestId" => @contestId, "name" => @name, "ranked" => @ranked, "multiplicity" => @multiplicity, "writeIn" => @writeIn, "candidates" => @candidates.map(&:as_json) } end |