-
Notifications
You must be signed in to change notification settings - Fork 0
/
recipe_website.dart
34 lines (25 loc) · 926 Bytes
/
recipe_website.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import '../recipe_parser/recipe_parser.dart';
/// Enum for the supported recipe websites.
enum RecipeWebsite {
/// KptnCook.
kptnCook("mobile.kptncook.com", KptnCookParser()),
/// Bianca Zapatka.
biancaZapatka("biancazapatka.com", BiancaZapatkaParser()),
/// Eat This.
eatThis("www.eat-this.org", EatThisParser()),
/// Chefkoch.
chefkoch("www.chefkoch.de", ChefkochParser()),
/// Nora Cooks.
noraCooks("www.noracooks.com", NoraCooksParser());
/// Returns the [RecipeWebsite] for the passed [url].
///
/// Returns null if the passed [url] is not supported.
static RecipeWebsite? fromUrl(Uri url) => RecipeWebsite.values
.where((website) => website.urlHost == url.host)
.firstOrNull;
const RecipeWebsite(this.urlHost, this.recipeParser);
/// The host of the website url.
final String urlHost;
/// The [RecipeParser] for this website.
final RecipeParser recipeParser;
}