Election (Vote v0.1.0) View Source

Link to this section Summary

Link to this section Functions

Specs

run() ::
  :quit
  | %Election{
      candidates: [%Candidate{id: term(), name: term(), votes: term()}],
      name: binary(),
      next_id: number()
    }

Updates Election Struct, based on provided command.

Parameters

  • election: Election struct
  • cmd: String based command. Each command can be shortened to what's shown in parenthesis.
    • (n)ame command updates the election name
      • example: "n mayor"
    • (a)dd command adds a new candidate
      • example: "a Tina Fey"
    • (v)ote command increments the vote count for each candidate
      • example: "v 1"
    • (q)uit command returns a quit atom
      • example: "q"

Returns Election struct

Examples

iex> %Election{} |> Election.update("n Mayor")
%Election{name: "Mayor"}