Class: ClearElection::Election::Agent

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(uri:) ⇒ Agent

Returns a new instance of Agent.



88
89
90
# File 'lib/clear-election-sdk/election.rb', line 88

def initialize(uri:)
  @uri = Addressable::URI.parse(uri)
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



86
87
88
# File 'lib/clear-election-sdk/election.rb', line 86

def uri
  @uri
end

Class Method Details

.from_json(data) ⇒ Object



92
93
94
# File 'lib/clear-election-sdk/election.rb', line 92

def self.from_json(data)
  self.new(uri: data["uri"].sub(%r{/?$}, '/'))
end

Instance Method Details

#as_jsonObject



96
97
98
99
100
# File 'lib/clear-election-sdk/election.rb', line 96

def as_json()
  {
    "uri" => @uri.to_s
  }
end