recipe

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDivideByZero error = fmt.Errorf("fraction: can't divide by 0")

Functions

This section is empty.

Types

type Fraction

type Fraction struct {
	Numerator   int `json:"numerator"`
	Denominator int `json:"denominator"`
}

func MakeCopyFraction

func MakeCopyFraction(prev Fraction) Fraction

func MakeFraction

func MakeFraction(numerator int, denominator int) (Fraction, error)

func (*Fraction) Divide

func (this *Fraction) Divide(num int) error

func (*Fraction) Multiply

func (this *Fraction) Multiply(num int)

func (*Fraction) Reduce

func (this *Fraction) Reduce()

func (Fraction) String

func (this Fraction) String() string

func (Fraction) Value

func (this Fraction) Value() float32

type Ingredient

type Ingredient struct {
	Measurement `json:"measurement"`
	Name        string `json:"name"`
}

func MakeIngredient

func MakeIngredient(numerator int, denominator int, unit string, name string) (Ingredient, error)

func (Ingredient) String

func (this Ingredient) String() string

type Measurement

type Measurement struct {
	Fraction `json:"fraction"`
	Unit     string `json:"unit"`
}

func MakeMeasurement

func MakeMeasurement(numerator int, denominator int, unit string) (Measurement, error)

func (Measurement) String

func (this Measurement) String() string

type Recipe

type Recipe struct {
	Title       string          `json:"title"`
	Author      string          `json:"author"`
	Ingredients []Ingredient    `json:"ingredients"`
	Directions  []string        `json:"directions"`
	Tags        map[string]bool `json:"tags"`
	ID          int             `json:"id"`
}

func MakeRecipe

func MakeRecipe(title string, author string, Ingredients []Ingredient, Directions []string, tags map[string]bool) Recipe

func NewRecipe

func NewRecipe(title string, author string) Recipe

func (*Recipe) AddDirection

func (this *Recipe) AddDirection(direction string)

func (*Recipe) AddIngredient

func (this *Recipe) AddIngredient(numerator int, denominator int, unit string, name string) error

func (*Recipe) AddTag

func (this *Recipe) AddTag(tag string)

func (*Recipe) RemoveDirection

func (this *Recipe) RemoveDirection(index int) error

func (*Recipe) RemoveIngredient

func (this *Recipe) RemoveIngredient(index int) error

func (*Recipe) RemoveTag

func (this *Recipe) RemoveTag(tag string)

func (*Recipe) ScaleDownRecipe

func (this *Recipe) ScaleDownRecipe(scalar int) error

func (*Recipe) ScaleUpRecipe

func (this *Recipe) ScaleUpRecipe(scalar int)

func (Recipe) String

func (this Recipe) String() string

func (*Recipe) SwapDirections

func (this *Recipe) SwapDirections(indexArray []int) error

func (*Recipe) SwapIngredients

func (this *Recipe) SwapIngredients(indexArray []int) error

Jump to

Keyboard shortcuts

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