recipe

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Day = (24 * time.Hour)
View Source
const Week = (7 * 24 * time.Hour)
View Source
const Year = (365 * 24 * time.Hour)

Variables

This section is empty.

Functions

func FormatCookingRational

func FormatCookingRational(num float64) (s string)

func FormatCost

func FormatCost(cost float64) (s string)

func FormatDuration

func FormatDuration(hours float64) (s string)

func FormatMeasure

func FormatMeasure(amount float64, measure string) (s string)

func GetMD5Hash

func GetMD5Hash(text string) string

func SetLogLevel

func SetLogLevel(level string) (err error)

SetLogLevel determines the log level

Types

type Dag

type Dag struct {
	ParallelHours float64   `toml:"p_hours" json:"p_hours,omitempty"`
	SerialHours   float64   `toml:"s_hours" json:"s_hours,omitempty"`
	Directions    string    `toml:"directions" json:"directions,omitempty"`
	Notes         string    `toml:"notes" json:"notes,omitempty"`
	Product       Element   `toml:"product" json:"product,omitempty"`
	Reactant      []Element `toml:"reactant" json:"reactant,omitempty"`
	Children      []*Dag
}

Dag is the format that the reactions are parsed into. Each root only corresponds to a single Product (which is different than a Reaction). The children correspond to dags of the reactions of the reactants. Everything else is pretty much carried over from the reaction.

type Element

type Element struct {
	// Name is the name of the product/reactant
	Name string `toml:"name" json:"name,omitempty"`

	// Amount is the amount
	Amount float64 `toml:"amount" json:"amount,omitempty"`

	// Measure is the type of measurement, either
	// "grams" (weight), "cups" (volume), "acres" (sq ft),
	// or "whole"
	Measure string `toml:"measure" json:"measure,omitempty"`

	// Price is the cost per amount+measure, specified on products.
	Price float64 `toml:"price" json:"price,omitempty"`

	// Notes are for references
	Notes string `toml:"notes" json:"notes,omitempty"`
}

type Reaction

type Reaction struct {
	// ParallelHours it takes to create the products from reactants, in parallel.
	// For example, trees grow at the same rate no matter how many there are,
	// so there time cost would be almost entirely "parallel". Parallel time
	// does not scale when scaling the recipe
	ParallelHours float64 `toml:"p_hours" json:"p_hours,omitempty"`

	// SerialHours is the serial amount of time needed, time that scales
	// proportional to the quantities.
	SerialHours float64 `toml:"s_hours" json:"s_hours,omitempty"`

	Directions string    `toml:"directions" json:"directions,omitempty"`
	Notes      string    `toml:"notes" json:"notes,omitempty"`
	Product    []Element `toml:"product" json:"product,omitempty"`
	Reactant   []Element `toml:"reactant" json:"reactant,omitempty"`

	// LastUpdated is the year it was last updated
	// (refers to the price)
	LastUpdated time.Time `toml:"updated" json:"updated,omitempty"`
}

Reaction is the reaction that takes place, with reactants and products in either their theoretical OR practical lowest irreducible. This is the format of the toml file for all the recipes.

type Reactions

type Reactions struct {
	Reactions []Reaction `toml:"reaction"`
}

type RequestFromApp

type RequestFromApp struct {
	Amount             float64             `json:"amount"`
	Measure            string              `json:"measure"`
	Recipe             string              `json:"recipe"`
	IngredientsToBuild map[string]struct{} `json:"ingredientsToBuild"`
	MinutesToBuild     float64             `json:"minutes"`
}

type UpdateApp

type UpdateApp struct {
	MinutesToBuild float64                `json:"minutes"`
	Graph          string                 `json:"graph"`
	Version        string                 `json:"version"`
	Recipe         string                 `json:"recipe"`
	Amount         float64                `json:"amount"`
	Measure        string                 `json:"measure"`
	TotalCost      string                 `json:"totalCost"`
	TotalTime      string                 `json:"totalTime"`
	Ingredients    []UpdateAppIngredients `json:"ingredients"`
	Directions     []UpdateAppDirections  `json:"directions"`
}

func GetRecipe

func GetRecipe(recipe string, amountSpecified float64, hours float64, ingredientsToInclude map[string]struct{}) (payload UpdateApp, err error)

type UpdateAppDirections

type UpdateAppDirections struct {
	Name      string   `json:"name"`
	TotalTime string   `json:"totalTime"`
	Texts     []string `json:"texts"`
}

type UpdateAppIngredients

type UpdateAppIngredients struct {
	Amount      string `json:"amount"`
	Name        string `json:"name"`
	Cost        string `json:"cost"`
	ScratchTime string `json:"scratchTime"`
	ScratchCost string `json:"scratchCost"`
}

Jump to

Keyboard shortcuts

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