Class: ClearElection::Election::Candidate

Inherits:
Object
  • Object
show all
Defined in:
lib/clear-election-sdk/election.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(candidateId:, name:) ⇒ Candidate

Returns a new instance of Candidate.



143
144
145
146
# File 'lib/clear-election-sdk/election.rb', line 143

def initialize(candidateId:, name:)
  @candidateId = candidateId
  @name = name
end

Instance Attribute Details

#candidateIdObject (readonly)

Returns the value of attribute candidateId.



141
142
143
# File 'lib/clear-election-sdk/election.rb', line 141

def candidateId
  @candidateId
end

Class Method Details

.from_json(data) ⇒ Object



148
149
150
151
152
153
# File 'lib/clear-election-sdk/election.rb', line 148

def self.from_json(data)
  self.new(
    candidateId: data["candidateId"],
    name: data["name"]
  )
end

Instance Method Details

#as_jsonObject



155
156
157
158
159
160
# File 'lib/clear-election-sdk/election.rb', line 155

def as_json
  {
    "candidateId" => @candidateId,
    "name" => @name
  }
end