model

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: ISC Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Categories

type Categories []Category

Categories is a collection of Category

func (Categories) Len

func (c Categories) Len() int

Len returns the length of the Categories

func (Categories) Less

func (c Categories) Less(i, j int) bool

Less compares two Category in the Categories and returns bool true if i is less than j

func (Categories) Swap

func (c Categories) Swap(i, j int)

Swap two Category in Categories

func (Categories) ToSnippets

func (c Categories) ToSnippets() *Snippets

ToSnippets will collect all the Snippets in the Categories

type Category

type Category struct {
	Name     string   // category name
	Snippets Snippets // snippets in the category
}

Category is a named set of Snippets

type Preferences

type Preferences struct {
	DefaultFile string `json:"defaultFile"` // users default snippets file
}

Preferences represents a users preferences.

func ReadPreferences

func ReadPreferences(filename string) (*Preferences, error)

ReadPreferences reads the file indicated by filename and returns a *Preferences structure. If the filename is empty it will look for the default preferences file. If no file can be be found or the file is malformed an error is returned.

func (*Preferences) Write added in v1.0.0

func (p *Preferences) Write(filename string) error

Write the preferences as JSON to filename.

type SetCategories

type SetCategories interface {
	Categories(categories *Categories)
}

SetCategories is an interface indicating the ability to set Categories

type Snippet

type Snippet struct {
	Category string `json:"category"` // category of the snippet
	Title    string `json:"title"`    // title of the snippet
	Body     string `json:"body"`     // body of the snippet
}

Snippet defines a snippet

func (Snippet) String

func (s Snippet) String() string

Implement fmt.Stringer

type Snippets

type Snippets []Snippet

Snippets is a collection of Snippet

func ReadSnippets

func ReadSnippets(filename string) (Snippets, error)

ReadSnippets accepts a filename, reads from the file and returns the Snippets found in the file.

func (Snippets) ByCategory

func (s Snippets) ByCategory() Categories

ByCategory splits Snippets into their Category.

func (Snippets) Len

func (s Snippets) Len() int

Len returns the length of the Snippets.

func (Snippets) Less

func (s Snippets) Less(i, j int) bool

Less compares two Snippet.

func (Snippets) Swap

func (s Snippets) Swap(i, j int)

Swap swaps two Snippet in the Snippets.

func (*Snippets) WriteSnippets

func (s *Snippets) WriteSnippets(filename string) error

WriteSnippets writes Snippets to the file named.

Jump to

Keyboard shortcuts

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