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.



130
131
132
133
# File 'lib/clear-election-sdk/election.rb', line 130

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

Instance Attribute Details

#candidateIdObject (readonly)

Returns the value of attribute candidateId.



128
129
130
# File 'lib/clear-election-sdk/election.rb', line 128

def candidateId
  @candidateId
end

Class Method Details

.from_json(data) ⇒ Object



135
136
137
138
139
140
# File 'lib/clear-election-sdk/election.rb', line 135

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

Instance Method Details

#as_jsonObject



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

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