renderer

package
v0.0.0-...-1b63e00 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONRenderer

type JSONRenderer struct{}

JSONRenderer is the JSON renderer

func (*JSONRenderer) AddEntry

func (r *JSONRenderer) AddEntry(date string, calories int, food string) (string, error)

AddEntry displays a success message after adding an entry

func (*JSONRenderer) AddWeight

func (r *JSONRenderer) AddWeight(weight float64, config *model.Config) (string, error)

AddWeight renders a success message and the added weight

func (*JSONRenderer) ClearEntries

func (r *JSONRenderer) ClearEntries(date string) (string, error)

ClearEntries displays a success message after clearing the entries for a day

func (*JSONRenderer) ClearEntry

func (r *JSONRenderer) ClearEntry(date string, entry *model.Entry) (string, error)

ClearEntry displays a success message after clearing the entry at a given position for a day

func (*JSONRenderer) Config

func (r *JSONRenderer) Config(config *model.Config, weight *model.Weight, amr, bmr float64, age int) (string, error)

Config prints the given configuration with weight, amr and bmr

func (*JSONRenderer) Days

func (r *JSONRenderer) Days(days model.Days, from, to time.Time) (string, error)

Days renders the days in the given timespan

func (*JSONRenderer) Error

func (r *JSONRenderer) Error(err error) (string, error)

Error renders an error

func (*JSONRenderer) Export

func (r *JSONRenderer) Export(impex *model.ImpEx) (string, error)

Export returns the export data as JSON

func (*JSONRenderer) Import

func (r *JSONRenderer) Import(fileName string, numEntries, numWeights int) (string, error)

Import displays a success message after importing from a file

func (*JSONRenderer) WeightHistory

func (r *JSONRenderer) WeightHistory(weights []model.Weight, config *model.Config) (string, error)

WeightHistory renders all weights in order and their dates

type Renderer

type Renderer interface {
	Error(err error) (string, error)
	WeightHistory(weights []model.Weight, config *model.Config) (string, error)
	AddWeight(weight float64, config *model.Config) (string, error)
	Config(config *model.Config, weight *model.Weight, amr, bmr float64, age int) (string, error)
	Days(days model.Days, from, to time.Time) (string, error)
	AddEntry(date string, calories int, food string) (string, error)
	ClearEntries(date string) (string, error)
	ClearEntry(date string, entry *model.Entry) (string, error)
	Import(fileName string, numEntries, numWeights int) (string, error)
}

Renderer is the interface for rendering any output

type TerminalRenderer

type TerminalRenderer struct{}

TerminalRenderer is the renderer for the CLI

func (*TerminalRenderer) AddEntry

func (r *TerminalRenderer) AddEntry(date string, calories int, food string) (string, error)

AddEntry displays a success message after adding an entry

func (*TerminalRenderer) AddWeight

func (r *TerminalRenderer) AddWeight(weight float64, config *model.Config) (string, error)

AddWeight renders a success message and the added weight

func (*TerminalRenderer) ClearEntries

func (r *TerminalRenderer) ClearEntries(date string) (string, error)

ClearEntries displays a success message after clearing the entries for a day

func (*TerminalRenderer) ClearEntry

func (r *TerminalRenderer) ClearEntry(date string, entry *model.Entry) (string, error)

ClearEntry displays a success message after clearing the entry at a given position for a day

func (*TerminalRenderer) Config

func (r *TerminalRenderer) Config(config *model.Config, weight *model.Weight, amr, bmr float64, age int) (string, error)

Config prints the given configuration with weight, amr and bmr

func (*TerminalRenderer) Days

func (r *TerminalRenderer) Days(days model.Days, from, to time.Time) (string, error)

Days renders the days in the given timespan

func (*TerminalRenderer) Error

func (r *TerminalRenderer) Error(err error) (string, error)

Error renders an error

func (*TerminalRenderer) Import

func (r *TerminalRenderer) Import(fileName string, numEntries, numWeights int) (string, error)

Import displays a success message after importing from a file

func (*TerminalRenderer) WeightHistory

func (r *TerminalRenderer) WeightHistory(weights []model.Weight, config *model.Config) (string, error)

WeightHistory renders all weights in order and their dates

Jump to

Keyboard shortcuts

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