Explorar el Código

Implement Juvenes ForceMajoure rule.

Toni Fadjukoff hace 11 años
padre
commit
bce2c2f9e7
Se han modificado 1 ficheros con 18 adiciones y 9 borrados
  1. 18 9
      juvenes.pl

+ 18 - 9
juvenes.pl Ver fichero

@@ -111,16 +111,25 @@ sub get_juvenes_restaurants {
111 111
           my $mealoptions = $data->{'MealOptions'};
112 112
           # loop different meals
113 113
           foreach my $meal_info (@$mealoptions) {
114
-            my $menuitems = $meal_info->{'MenuItems'};
115
-            # loops different foods in a meal
116
-            foreach my $food_info (@$menuitems) {
117
-              $cur_food .= "\n" if $cur_food ne ""; 
118
-              my $name = $food_info->{'Name'};
119
-              $name =~ s/^\*//;
120
-              $cur_food .= $name;
121
-              $cur_food .= " (" . $food_info->{'Diets'} . ")" if $food_info->{'Diets'};
114
+            print $meal_info->{'ForceMajeure'} . "\n" if $meal_info->{'ForceMajeure'} ne '';
115
+            if ($meal_info->{'ForceMajeure'} ne '') {
116
+              $cur_food = $meal_info->{'ForceMajeure'}; 
117
+            } else {
118
+              my $menuitems = $meal_info->{'MenuItems'};
119
+              # loops different foods in a meal
120
+              foreach my $food_info (@$menuitems) {
121
+                $cur_food .= "\n" if $cur_food ne ""; 
122
+                my $name = $food_info->{'Name'};
123
+                $name =~ s/^\*//;
124
+                $cur_food .= $name;
125
+                $cur_food .= " (" . $food_info->{'Diets'} . ")" if $food_info->{'Diets'};
126
+              }
127
+            }
128
+            if ($cur_food ne "-") {
129
+              finish_food();
130
+            } else {
131
+              $cur_food = "";
122 132
             }
123
-            finish_food();
124 133
           }
125 134
         }
126 135
         finish_day();