Documentation ¶
Index ¶
Constants ¶
const URL = "https://sandsmad.dk/"
Variables ¶
var DayRegexes = []DayMatcher{ { NameOfDay: "Mandag", Regex: regexp.MustCompile(`(?i)Mandag\s([\S\s]*)\sTirsdag`), }, { NameOfDay: "Tirsdag", Regex: regexp.MustCompile(`(?i)Tirsdag\s([\S\s]*)\sOnsdag`), }, { NameOfDay: "Onsdag", Regex: regexp.MustCompile(`(?i)Onsdag\s([\S\s]*)\sTorsdag`), }, { NameOfDay: "Torsdag", Regex: regexp.MustCompile(`(?i)Torsdag\s([\S\s]*)\sFredag`), }, { NameOfDay: "Fredag", Regex: regexp.MustCompile(`(?i)Fredag\s([\S\s]*)\sMonday`), }, }
DayRegexes is a slice of DayMatcher for each weekday
var ErrWeekdayNotDishDay = errors.New("weekday is not a dish day")
Functions ¶
This section is empty.
Types ¶
type DayMatcher ¶
DayMatcher is a struct containing a regular expression for matching the lines that describes a dish on a particular day
func (DayMatcher) Match ¶
func (dm DayMatcher) Match(page *SandsPage) (*DishOfTheDay, error)
Match takes a menu and returns a DishOfTheDay parsing the menu using the DayMatcher
type DishOfTheDay ¶
type DishOfTheDay struct { NameOfDay DishDay `json:"name_of_day"` ShortDescription string `json:"short_description"` Lines []string `json:"lines"` }
DishOfTheDay is a struct containing a dish of the day. A slice of lines describes the dish and the short description provides a summary of the main dish
func FetchThisWeeksDishes ¶
func FetchThisWeeksDishes() ([]DishOfTheDay, error)
FetchThisWeeksDishes fetches this weeks dishes using the default fetcher
func FetchThisWeeksDishesWithClient ¶
func FetchThisWeeksDishesWithClient(client *http.Client) ([]DishOfTheDay, error)
FetchThisWeeksDishesWithClient fetches this weeks dishes using the provided client in the fetcher
func FetchThisWeeksDishesWithFetcher ¶
func FetchThisWeeksDishesWithFetcher(fetcher func() ([]byte, error)) ([]DishOfTheDay, error)
FetchThisWeeksDishesWithFetcher fetching, parses and maps this weeks dishes using the provided fetcher
func (DishOfTheDay) IsDishOnTheMenuAt ¶ added in v1.0.4
func (dish DishOfTheDay) IsDishOnTheMenuAt(t time.Time) (error, bool)
func (DishOfTheDay) IsDishOnTheMenuToday ¶ added in v1.0.4
func (dish DishOfTheDay) IsDishOnTheMenuToday() (error, bool)