Documentation ¶
Overview ¶
Package bananas is a Go library for interfacing with the dining hall menus at the University of California Santa Cruz
Origins ¶
At UCSC there are five (5) dining halls. One for each pair of colleges in the ten college system.
Each dining hall has it's own menu that can be viewed online here: https://nutrition.sa.ucsc.edu Many students have built third party menu viewers -- each with their own method of parsing the website (manual web scraping is necessary as there is no public API). And this is where bananas comes in. Bananas will serve as the engine for a new API server that is in development, so that students can build custom web views, apps etc. .
Bananas will also be available for everyone, so that they too can build awesome stuff with it.
Usage ¶
To use bananas simply call MenuFor with one item from each of the following lists:
Dining Halls (Choose one (1)):
bananas.PorterKresge // Porter and Kresge Dining Hall bananas.NineTen // College Nine and Ten Dining Hall bananas.CowellStevenson // Cowell and Steventson Dining Hall bananas.CarsonOakes // Rachel Carson and Oakes Dining Hall bananas.CrownMerrill // Crown and Merrill Dining Hall
Meals (Choose one (1)):
bananas.Breakfast // For breakfast bananas.Lunch // For lunch bananas.Dinner // For dinner bananas.LateNight // For late night
Time:
Any struct that is time.Time will satisfy this parameter. Note that the actual time (e.g 12:00PM) is ignored and only the date is used.
Examples ¶
Here are some common uses for bananas.
// Get the lunch menu for today's meal at RCC and Oakes Dining Hall. banana.MenuFor(bananas.CarsonOakes, bananas.Lunch, time.Now()) // For tomorrow's dinner menu at College 9 & 10. banana.MenuFor(bananas.NineTen, bananas.Dinner, time.Now().Add(24 * time.Hour))
Note that each of these calls will make two (2) http requests. One for the menu data, and another to set the cookies.
If you would like to only have one http request per call use bananas.Client
// Make a client. c := bananas.Client{} // Get the menu as normal. c.MenuFor(bananas.CarsonOakes, bananas.Lunch, time.Now())
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // NineTen is the Nine & Ten Dining Hall NineTen = DiningHall{ LocationName: "Colleges Nine & Ten Dining Hall", LocationNumber: "40", } // CowellStevenson is the Cowell Stevenson Dining Hall CowellStevenson = DiningHall{ LocationName: "Cowell Stevenson Dining Hall", LocationNumber: "05", } // CrownMerrill is the Crown Merrill Dining Hall CrownMerrill = DiningHall{ LocationName: "Crown Merrill Dining Hall", LocationNumber: "20", } // PorterKresge is the Porter Kresge Dining Hall PorterKresge = DiningHall{ LocationName: "Porter Kresge Dining Hall", LocationNumber: "25", } // CarsonOakes is the Rachel Carson Oakes Dining Hall CarsonOakes = DiningHall{ LocationName: "Rachel Carson Oakes Dining Hall", LocationNumber: "30", } )
Functions ¶
Types ¶
type Client ¶ added in v0.0.3
type Client struct {
// contains filtered or unexported fields
}
Client is meant to be used when multiple menus want to be accessed.
It is preferred over MenuFrom because it will avoid making a call to the main UCSC nutritional page for cookies.
type DiningHall ¶
DiningHall represents a dining hall according to UCSC's nutritional website.