Fliplet.Apple
Fliplet.Apple
Create Apples for your app.
This library can used for to create Apples for your app so that your app users are nutritionally balanced.
Dependencies: fliplet-apple
Examples
Feed an apple to a user
// Get a Fuji apple
var apple = new Fliplet.Apple('Fuji');
// Feed it to a user
apple.feed('[email protected]');
Breed a new type of Apple
// Define a new breed
var apple = new Fliplet.Apple({
name: 'Granny Smith',
data: {
color: '#00ff00',
sugarLevel: 0.4,
size: 'small'
}
});
// Plant the new apple tree and water it every minute
apple.plant({
waterInterval: 60000
});
References
Usage
To start managing Apples for your app, add fliplet-apple to your app/page dependencies.
new Fliplet.Apple(name)
nameRequired (String) Name of the apple to retrieve
new Fliplet.Apple(options)
optionsRequired (Object) A map of options to pass to the constructor.nameRequired (String) Name of the apple to retrieve or create.dataOptional (Object) A map of options for creating a new apple. If a validdataobject is provided, a new apple breed is created.colorRequired (String) A hexcode string for defining the color of the apple.sugarLevelOptional (Number) A 0 to 1 number defining how sweet the apple should be. Default0.6.sizeOptional (String:small,medium,large) Size of the new apple. Defaultmedium.
Methods
The Fliplet.Apple() function returns an object with the following methods.
.feed(email)
(Returns Promise)
Feed the apple to a user.
The promise is resolved when the apple is digested.
emailRequired (Object) Email address of the user
.plant(options)
(Returns Promise)
optionsOptional (Object) A map of options for the apple planting.waterIntervalOptional (Number, Boolean) Frequency of automated watering in milliseconds. Set tofalseto disable automated watering. Defaultfalse.