Class: ClearElection::Ballot::Choice
- Inherits:
-
Object
- Object
- ClearElection::Ballot::Choice
- Defined in:
- lib/clear-election-sdk/ballot.rb
Instance Attribute Summary collapse
-
#candidateId ⇒ Object
readonly
Returns the value of attribute candidateId.
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
Class Method Summary collapse
Instance Method Summary collapse
- #abstain? ⇒ Boolean
- #as_json ⇒ Object
- #candidate? ⇒ Boolean
-
#initialize(candidateId:, rank: nil) ⇒ Choice
constructor
A new instance of Choice.
- #writeIn? ⇒ Boolean
Constructor Details
#initialize(candidateId:, rank: nil) ⇒ Choice
Returns a new instance of Choice.
125 126 127 128 |
# File 'lib/clear-election-sdk/ballot.rb', line 125 def initialize(candidateId:, rank: nil) @candidateId = candidateId @rank = rank end |
Instance Attribute Details
#candidateId ⇒ Object (readonly)
Returns the value of attribute candidateId.
124 125 126 |
# File 'lib/clear-election-sdk/ballot.rb', line 124 def candidateId @candidateId end |
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
124 125 126 |
# File 'lib/clear-election-sdk/ballot.rb', line 124 def rank @rank end |
Class Method Details
.from_json(data, rank: nil) ⇒ Object
142 143 144 145 |
# File 'lib/clear-election-sdk/ballot.rb', line 142 def self.from_json(data, rank: nil) self.new(candidateId: data["candidateId"], rank: rank) end |
Instance Method Details
#abstain? ⇒ Boolean
134 135 136 |
# File 'lib/clear-election-sdk/ballot.rb', line 134 def abstain? @candidateId == "ABSTAIN" end |
#as_json ⇒ Object
147 148 149 150 151 |
# File 'lib/clear-election-sdk/ballot.rb', line 147 def as_json { "candidateId" => @candidateId } end |
#candidate? ⇒ Boolean
138 139 140 |
# File 'lib/clear-election-sdk/ballot.rb', line 138 def candidate? not (writeIn? or abstain?) end |
#writeIn? ⇒ Boolean
130 131 132 |
# File 'lib/clear-election-sdk/ballot.rb', line 130 def writeIn? @candidateId.start_with?("WRITEIN:") end |