summaryrefslogtreecommitdiff
path: root/src/candidates.adb
blob: b95e48005eb7697a62bae453f6c8767af69f0e3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69


with CSV;


--  This source is licensed under Creative Commons CC0 v1.0.
--
--  To read the full text, see license.txt in the main directory of this repository
--  or go to https://creativecommons.org/publicdomain/zero/1.0/legalcode.txt
--
--  For a human readable summary, go to https://creativecommons.org/publicdomain/zero/1.0/


package body Candidates is


    function To_String
           (Input_Candidate : in Candidate;
            Delimiter       : in Character := ',')
        return String
    is
        package My_CSV is new CSV (Delimiter => Delimiter);
        use type My_CSV.String_Vectors.Vector;

        My_Record : My_CSV.CSV_Record;
    begin
        My_Record :=
            My_CSV.String_Vectors.Empty_Vector &
            Input_Candidate.Group &
            Input_Candidate.Group_Rank &
            Input_Candidate.First_Name &
            Input_Candidate.Last_Name &
            Input_Candidate.Party;
        return My_CSV.Unparse_Record (My_Record);
    end To_String;




    function Candidate_Header
           (Delimiter : in Character := ',')
        return String is
    begin
        return "Group" & Delimiter &
               "Group Rank" & Delimiter &
               "First Name" & Delimiter &
               "Last Name" & Delimiter &
               "Party";
    end Candidate_Header;




    function Name_And_Party
           (Input_Candidate : in Candidate)
        return String
    is
        use type SU.Unbounded_String;
    begin
        return SU.To_String
           (Input_Candidate.First_Name & " " &
            Input_Candidate.Last_Name & ", " &
            Input_Candidate.Party);
    end Name_And_Party;


end Candidates;