formatter

package
v0.0.0-...-93177db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CsvFormatter

type CsvFormatter struct{}

CsvFormatter formats the results as CSV, with , as delimiter and " as quote

func (*CsvFormatter) Format

func (t *CsvFormatter) Format(
	_ *judgment.PollTally,
	result *judgment.PollResult,
	proposals []string,
	grades []string,
	options *Options,
) (string, error)

Format the provided results

type Formatter

type Formatter interface {
	// Format the provided results
	Format(
		pollTally *judgment.PollTally,
		result *judgment.PollResult,
		proposals []string,
		grades []string,
		options *Options,
	) (string, error)
}

Formatter to implement to make another formatter Keep in mind you need to add it to the "if else if" in root command as well

type GnuplotMeritFormatter

type GnuplotMeritFormatter struct{}

GnuplotMeritFormatter creates a script for gnuplot that displays the merit profiles

func (*GnuplotMeritFormatter) Format

func (t *GnuplotMeritFormatter) Format(
	pollTally *judgment.PollTally,
	result *judgment.PollResult,
	proposals []string,
	grades []string,
	options *Options,
) (string, error)

Format the provided results in the gnuplot script form

type GnuplotOpinionFormatter

type GnuplotOpinionFormatter struct{}

GnuplotOpinionFormatter creates a script for gnuplot that shows the opinion profile

func (*GnuplotOpinionFormatter) Format

func (t *GnuplotOpinionFormatter) Format(
	pollTally *judgment.PollTally,
	result *judgment.PollResult,
	proposals []string,
	grades []string,
	options *Options,
) (string, error)

Format the provided results

type JsonFormatter

type JsonFormatter struct{}

JsonFormatter formats the output as … JSON All on one line, feel free to make an option if you can figure out how to beautify it

func (*JsonFormatter) Format

func (t *JsonFormatter) Format(
	tally *judgment.PollTally,
	result *judgment.PollResult,
	proposals []string,
	grades []string,
	options *Options,
) (string, error)

Format the provided results

type Options

type Options struct {
	Colorized  bool
	Scale      float64 // so we can use integers internally, and display floats
	Sorted     bool
	Terminal   string // User-defined gnuplot terminal, only used by gnuplot formatters
	Width      int
	GreenToRed bool // horizontal order of the grades in the merit profiles and such
}

Options are shared between all formatters. Some formatters may ignore some options.

type SvgMeritFormatter

type SvgMeritFormatter struct{}

SvgMeritFormatter renders merit profiles as SVG

func (*SvgMeritFormatter) Format

func (t *SvgMeritFormatter) Format(
	_ *judgment.PollTally,
	result *judgment.PollResult,
	proposals []string,
	_ []string,
	options *Options,
) (string, error)

Format the provided results in the gnuplot script form

type TextFormatter

type TextFormatter struct{}

TextFormatter is the default formatter. It displays the proposals with their merit profiles and ranks.

func (*TextFormatter) Format

func (t *TextFormatter) Format(
	pollTally *judgment.PollTally,
	result *judgment.PollResult,
	proposals []string,
	grades []string,
	options *Options,
) (string, error)

Format the provided results

type TextOpinionFormatter

type TextOpinionFormatter struct{}

TextOpinionFormatter formats opinion profiles in ASCII

func (*TextOpinionFormatter) Format

func (t *TextOpinionFormatter) Format(
	pollTally *judgment.PollTally,
	result *judgment.PollResult,
	proposals []string,
	grades []string,
	options *Options,
) (string, error)

Format the provided results

type YamlFormatter

type YamlFormatter struct{}

YamlFormatter formats the results in YAML

func (*YamlFormatter) Format

func (t *YamlFormatter) Format(
	tally *judgment.PollTally,
	result *judgment.PollResult,
	proposals []string,
	grades []string,
	options *Options,
) (string, error)

Format the provided results

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL