1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Database and data model to be used by servers and clients
22 # A beer, with a name and description
29 # Description on the Web site
32 redef fun to_s
do return "<{name}: {desc}>"
35 # A collection of beer-related events
39 # New beers on the menu
40 var new_beers
= new Array[Beer]
42 # Beers that have left the menu
43 var gone_beers
= new Array[Beer]
45 # Beers that are on the menu today, and yesterday
46 var fix_beers
= new Array[Beer]
48 # Get a human pretty `Array[String]` version of `self`
49 fun to_email_content
: Array[String]
51 var content
= new Array[String]
54 for beer
in self.new_beers
do
55 content
.add
"+ {beer.name}: {beer.desc}"
59 for beer
in self.gone_beers
do
60 content
.add
"- {beer.name}: {beer.desc}"
64 for beer
in self.fix_beers
do
65 content
.add
" {beer.name}: {beer.desc}"
71 # Get a pretty and short version of `self`
72 fun to_email_title
: String
75 var new_beers_name
= new Array[String]
76 for beer
in self.new_beers
do new_beers_name
.add beer
.name
78 if not new_beers_name
.is_empty
then
79 return " (+ {new_beers_name.join(", ")})"