bells

This is an npm
module that helps with the computation of bell schedules.
Install
npm install --save bells
once it is published
Features
- Awesomeness
- Store names for certain periods, not necessarily numerical or in order
- Get the current period
- Get when the next bell is
- Have bells not associated with a specific period
- Guess the bell schedule for a specific day based on a given set of criteria
API
Times are passed around as instances of Moment()
.
When an argument is a time, Bells
attempts to parse it as a HH:mm
time (24hr
time). A date argument must be given in a format specified
here.
Bells(bellScheduleRepresentation)
Create a Bells
object. See below for the layout of
bellScheduleRepresentation
.
var Bells = require('bells');
var schedule = Bells({
periods: {
'1': ['7:33', '8:23'],
'2': ['8:29', '9:24'],
'3': ['9:30', '10:20'],
'4 (1st lunch)': ['10:26', '11:16'],
'5 (2nd lunch)': ['11:22', '12:12'],
'6 (3rd lunch)': ['12:18', '13:08'],
'7': ['13:14', '14:04'],
'8': ['14:10', '15:00'],
},
other: [
'7:15',
'7:25',
],
});
Bells#currentPeriod([now])
Get the name of the current period, or null. See above for more info about time
parameters.
schedule.currentPeriod('13:00');
schedule.currentPeriod('14:15');
schedule.currentPeriod('16:00');
Bells#nextBell([now])
Get the time of the next bell, as a Moment()
. See above for more info about
time parameters.
schedule.nextBell('7:10');
schedule.nextBell('8:23');
schedule.nextBell('16:00');
Bells#periods()
Get all class periods passed to the initializer.
schedule.periods();
Bells.allBells()
Get all bells in the schedule, sorted in ascending order.
schedule.allBells()
Bells.Predictor(criteria)
Create a Predictor
object. See below for the layout of criteria
.
Note that a predictor only associates a string to a specific set of criteria. It
does not associate a Bells
object to that string.
var Bells = require('bells');
var Predictor = Bells.Predictor({
'default': 'Normal Day',
'0': 'none',
'6': 'none',
'04/18/2014': 'none',
'04/17/2014': 'FCAT',
'04/22/2014': 'FCAT',
'04/23/2014': 'FCAT',
'04/14/2014': 'FCAT - Monday',
});
Predictor#predict([date])
Predict the bell schedule for a certain date, or today if omitted. (The date
must be a full month/day/year, in any format guessable by
Moment.)
Predictor.predict('2014-04-15');
Predictor.predict('2014-04-21');
Predictor.predict('2014-04-14');
Predictor.predict('2014-04-19');