models

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotModified error = errors.New("temporary file not modified")

Functions

func EditCardViaEditor added in v0.2.0

func EditCardViaEditor(card *Card) error

editCardViaEditor allows the user to edit a card by execing into their preferred editor. Any changes they make are made to the passed *models.Card. If the user exits without writing any changes, error is set to ErrNotModified.

Types

type Card

type Card struct {
	ID       string      `json:"id"`
	Deck     string      `json:"-"`
	Version  int         `json:"version"`
	Active   bool        `json:"active"`
	Modified bool        `json:"-"`
	Question string      `json:"question"`
	Answer   string      `json:"answer"`
	Reviews  ReviewSlice `json:"reviews"`
}

func NewCard

func NewCard(question string, answer string, deck string) *Card

func (*Card) Copy

func (card *Card) Copy() *Card

func (*Card) String added in v0.2.0

func (card *Card) String() string

type Deck

type Deck struct {
	Name    string  `json:"name"`
	Version int     `json:"version"`
	Active  bool    `json:"active"`
	Cards   []*Card `json:"cards"`
}

A Deck is a collection of Cards that are all related.

func NewDeck

func NewDeck(name string, active bool) *Deck

func (*Deck) Copy

func (deck *Deck) Copy() *Deck

type Review

type Review struct {
	Version  int          `json:"version"`
	Result   ReviewResult `json:"result"`
	Datetime time.Time    `json:"datetime"`
}

func NewReview

func NewReview(result ReviewResult) Review

type ReviewResult

type ReviewResult string
const (
	Failed ReviewResult = "failed"
	Hard   ReviewResult = "hard"
	Normal ReviewResult = "normal"
	Easy   ReviewResult = "easy"
)

type ReviewSlice

type ReviewSlice []Review

func (ReviewSlice) Len

func (reviews ReviewSlice) Len() int

func (ReviewSlice) Less

func (reviews ReviewSlice) Less(i, j int) bool

func (ReviewSlice) Swap

func (reviews ReviewSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳