core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package core implements key data structures and associated methods for working with filog formatted data

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareDates

func CompareDates(a Date, b Date) bool

CompareDates will return true if a < b and false if a >= b

func InsertWatchDate

func InsertWatchDate(f *Film, w *WatchDate)

InsertWatchDate will insert a given watch date into a film's linked list, preserving sort order.

Types

type Date

type Date struct {
	Year  int        // Year (e.g., 2014).
	Month time.Month // Month of the year (January = 1, ...).
	Day   int        // Day of the month, starting at 1.
}

a Date is a simple Y-M-d struct. why import civil.Date for just this struct?

func ParseDate

func ParseDate(s string) (Date, error)

ParseDate parses a date string of the format "YYYY-MM-DD" and returns a proper Date struct.

func (Date) String

func (d Date) String() string

type Film

type Film struct {
	Film        *FilmKey   // Pointer to associated FilmKey, so individual film structs can be easily passed around
	Link        url.URL    // Link to TMDb or arbitrary user-provided page
	WatchCount  int        // Number of times a film was watched
	WatchedList *WatchDate // Pointer to a linked list of dates the film was watched.
}

A Film is a value in a film hashmap

func (Film) String

func (f Film) String() string

type FilmKey

type FilmKey struct {
	Title string // Title of the film
	Year  int    // Release year of the film
}

A FilmKey is used to as a key in a film hashmap.

func (FilmKey) String

func (f FilmKey) String() string

type FilmMap

type FilmMap map[FilmKey]*Film

func (FilmMap) PrintExport

func (m FilmMap) PrintExport(reverse bool) string

PrintExport will return a list of filog(5) format entries in reverse chronological order, suitable for redirecting to a new filog file.

func (FilmMap) PrintRegular

func (m FilmMap) PrintRegular() string

Regular will display a map of films using the "grouped watches" format, sorted by film title and release year. TODO: add separate Log and Watchlist functions to print them both nicely

so you don't get "# watches: " for watchlists

type WatchDate

type WatchDate struct {
	Date   Date            // Date of this watch
	Notes  string          // User-provided notes for this entry
	Rating int             // Film rating for this entry. Should be clamped to 1-10
	Like   tribool.Tribool // yes if like was Y, no if N, maybe if not provided
	Next   *WatchDate      // Next item in list
}

A WatchDate is used as a node in a linked list of dates a film was watched

func (WatchDate) String

func (w WatchDate) String() string

Jump to

Keyboard shortcuts

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