Documentation ¶
Index ¶
- type JSONRenderer
- func (r *JSONRenderer) AddEntry(date string, calories int, food string) (string, error)
- func (r *JSONRenderer) AddWeight(weight float64, config *model.Config) (string, error)
- func (r *JSONRenderer) ClearEntries(date string) (string, error)
- func (r *JSONRenderer) ClearEntry(date string, entry *model.Entry) (string, error)
- func (r *JSONRenderer) Config(config *model.Config, weight *model.Weight, amr, bmr float64, age int) (string, error)
- func (r *JSONRenderer) Days(days model.Days, from, to time.Time) (string, error)
- func (r *JSONRenderer) Error(err error) (string, error)
- func (r *JSONRenderer) Export(impex *model.ImpEx) (string, error)
- func (r *JSONRenderer) Import(fileName string, numEntries, numWeights int) (string, error)
- func (r *JSONRenderer) WeightHistory(weights []model.Weight, config *model.Config) (string, error)
- type Renderer
- type TerminalRenderer
- func (r *TerminalRenderer) AddEntry(date string, calories int, food string) (string, error)
- func (r *TerminalRenderer) AddWeight(weight float64, config *model.Config) (string, error)
- func (r *TerminalRenderer) ClearEntries(date string) (string, error)
- func (r *TerminalRenderer) ClearEntry(date string, entry *model.Entry) (string, error)
- func (r *TerminalRenderer) Config(config *model.Config, weight *model.Weight, amr, bmr float64, age int) (string, error)
- func (r *TerminalRenderer) Days(days model.Days, from, to time.Time) (string, error)
- func (r *TerminalRenderer) Error(err error) (string, error)
- func (r *TerminalRenderer) Import(fileName string, numEntries, numWeights int) (string, error)
- func (r *TerminalRenderer) WeightHistory(weights []model.Weight, config *model.Config) (string, error)
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) ClearEntries ¶
func (r *JSONRenderer) ClearEntries(date string) (string, error)
ClearEntries displays a success message after clearing the entries for a day
func (*JSONRenderer) ClearEntry ¶
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) 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 ¶
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) ClearEntries ¶
func (r *TerminalRenderer) ClearEntries(date string) (string, error)
ClearEntries displays a success message after clearing the entries for a day
func (*TerminalRenderer) ClearEntry ¶
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) 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