DinnerChoice 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/README.md +156 -5
- data/docs/.DS_Store +0 -0
- data/docs/Activity_Diagram.png +0 -0
- data/docs/Ascii_art_banner.png +0 -0
- data/docs/Dinner_choice.png +0 -0
- data/docs/Plan_UML_Chart.png +0 -0
- data/lib/DinnerChoice/controllers/DinnerChoiceController.rb +105 -0
- data/lib/DinnerChoice/models/Restaurants.rb +9 -0
- data/lib/DinnerChoice/repositories/RestaurantRepository.rb +42 -0
- data/lib/DinnerChoice/utils/capitalize.rb +3 -0
- data/lib/DinnerChoice/utils/dice_roller.rb +3 -0
- data/lib/DinnerChoice/utils/error.rb +9 -0
- data/lib/DinnerChoice/utils/heading_ascii.rb +10 -0
- data/lib/DinnerChoice/utils/line_separator.rb +6 -0
- data/lib/DinnerChoice/utils/menu_select.rb +36 -0
- data/lib/DinnerChoice/utils/waiting_dot.rb +8 -0
- data/lib/DinnerChoice/utils/wine_logo_ascii.rb +18 -0
- data/lib/DinnerChoice/version.rb +1 -1
- data/lib/DinnerChoice/views/RestaurantView.rb +77 -0
- data/lib/DinnerChoice.rb +26 -5
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54aefac41c06c280fd0e99308efe7a772b48f1ed6f62f34ecb0aad45e3a08912
|
4
|
+
data.tar.gz: 1a541c6dbf328af9fca1030ac208bc842813757a87a418a984b7b17d29ab0b96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3453a1a14eee17429bc350a47a32a1380c091a6597eaed079f0d56dddf919eed1be4d211e73470bbb17d08bac6a623455c27a1557090358650f474fe9e5dab9d
|
7
|
+
data.tar.gz: 47f5dbb152da329d948fc1bfb32124d3bb18a4fc24f2be6a9aeca7b9738f14ee95f138836f05329efec5ca58bc4a773809fe0b00548b4132b6905d612abae231
|
data/.DS_Store
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -1,11 +1,155 @@
|
|
1
1
|
# DinnerChoice
|
2
2
|
|
3
|
-
|
3
|
+
![avatar](./docs/Dinner_choice.png)
|
4
|
+
|
5
|
+
### Source control repository
|
6
|
+
|
7
|
+
* https://github.com/Lanzhou-J/DinnerChoice
|
8
|
+
|
9
|
+
### Statement of purpose and scope
|
10
|
+
|
11
|
+
This gem (terminal app) is designed to record information (e.g. name(brand), address, average price) and user-reviews of different restaurants. Users are able to add restaurants entry, display restaurants in a list format, delete any restaurant and update their information. Users can rate the restaurant on a scale of 1-5, 1 being the lowest(poor), 5 being the highest(great). Moreover, the app can help users make quick lunch/dinner decisions (or help users reach a consensus easily). Users can "roll a dice" to get a random selection from the up-to-date restaurants list.
|
12
|
+
|
13
|
+
With the progression of human civillization in this internet era, modern people are facing more and more choices (especially food choices !). Sometimes I even felt like I was drowning in infinite choices everyday. The original intention of designing this app is to help the people of modern fast-paced life to save time wasted on “making decisions on what to eat” and devote limited time and energy to more valuable things, such as reading, studying, writing ... (Or practice programming!)
|
14
|
+
|
15
|
+
Have you ever spent too much time trying to make a decision as where to go for lunch or dinner? Have you ever felt that making decisions inspires intense anxiety and relied on others to make decisions for you? Have you ever argued with your partner over which restaurant to choose for a romantic evening? No more "decidophobia", no more time-wasting...**The DinnerChoice app is designed just for you!**
|
16
|
+
|
17
|
+
With this app, you will be able to easily record, rate and compare different restaurants. When time is limited, or you are with lots of friends with different opinions and it is just too hard to decide your next dine out destination, just take a leap of faith and let the app make the decision for you.
|
18
|
+
|
19
|
+
### Features:
|
20
|
+
* Ascii art text banner in terminal header.
|
21
|
+
![avatar](docs/Ascii_art_banner.png)
|
22
|
+
|
23
|
+
* Create your resaurants collections. <br>
|
24
|
+
Users are able to create a new restaurant entry to record information related to the restaurant, including name(brand), location, price and their rating of the restaurant. After adding a new entry, the added restaurant will be appended to the bottom of the list with a new automatically generated ID.
|
25
|
+
|
26
|
+
* View name, address and price of restaurants -- information that you need to choose a restaurant for dine out. <br>
|
27
|
+
Users are able to select display function to view all restaurant entries in the current list. After editing (add, delete or update) the list displayed will change accordingly.
|
28
|
+
|
29
|
+
* Rate and review restaurants that you have been visited before.
|
30
|
+
|
31
|
+
* Update restaurants' information easily.<br>
|
32
|
+
Users are able to select which restaurant to edit and which attribute they want to change (name/ address/ rating and average price). Then they can input the new content of the attribute to overwrite the previous information.
|
33
|
+
|
34
|
+
* Delete any restaurant from you list. <br>
|
35
|
+
Users can delete any entry from the existing restaurants list. The ID of the restaurants in the list will automatically changed according to the latest order. However if there is nothing in the list the app will output an error message to remind the user to select function from main menu again.
|
36
|
+
|
37
|
+
* Make quick decisions.
|
38
|
+
|
39
|
+
### Outline of user interaction and experience
|
40
|
+
|
41
|
+
* The user will find out how to interact with the terminal app by reading the contents of "<font color="#dddd00">MAIN MENU</font>". Then users can select from the main menu (input number, select from 1 to 6). By doing so, they can choose to use each feature. After executing a function, the main menu list will display again and ask the user to select again. User can leave the app by inputing '6' (or '6.', 'exit').
|
42
|
+
|
43
|
+
```
|
44
|
+
MAIN MENU
|
45
|
+
1. Create a new restaurant entry
|
46
|
+
2. Display or search restaurants by key words
|
47
|
+
3. Delete an existing entry
|
48
|
+
4. Update info of an existing entry
|
49
|
+
5. Make a choice! (random generator)
|
50
|
+
6. Exit (or input "exit")
|
51
|
+
|
52
|
+
Please select from the MAIN MENU (select numbers 1 to 6):
|
53
|
+
> 6
|
54
|
+
See you next time!
|
55
|
+
```
|
56
|
+
|
57
|
+
* Error handling: when input wrong selection (e.g. '7', '9' or other numbers/letters), the app will output an error message an ask the user to select from the menu again.
|
58
|
+
```
|
59
|
+
Sorry, I don't understand. Please select from 1 to 6.
|
60
|
+
```
|
61
|
+
|
62
|
+
##### 1. Create new entry:
|
63
|
+
* After selecting "1" (or "1."). The user will be aksed to input the name (brand), address, rating and money usually spent(unit: AUD) of the restaurant (e.g. name:"Pappa Rich", address:"Southern cross station", rating:"3.5", average price:"9")
|
64
|
+
```
|
65
|
+
What's the name of the restaurant you'd like to add?
|
66
|
+
>
|
67
|
+
What's the address of the restaurant you'd like to add?
|
68
|
+
>
|
69
|
+
How do you like this restaurant? please rate on a scale of 1-5, 1 being the lowest(poor), 5 being the highest(great).
|
70
|
+
>
|
71
|
+
How much do you usually spend in this restaurant?
|
72
|
+
>
|
73
|
+
```
|
74
|
+
* After adding a new restaurant, the app will calculate if the list count has increased by 1, if yes, then output a message telling users that the new entry has been successfully added.
|
75
|
+
```
|
76
|
+
> > > > > > > > > > > > > > > > > >
|
77
|
+
New restaurant is successfully added!
|
78
|
+
```
|
79
|
+
##### 2. Display restaurants
|
80
|
+
* If nothing is added to the default restaurants list, the default restaurants list will be displayed as below:
|
81
|
+
```
|
82
|
+
-------------------------
|
83
|
+
ID: 1
|
84
|
+
Name: Pappa Rich
|
85
|
+
Address: Southern cross station, L1-CS-03
|
86
|
+
Rating: 3.5
|
87
|
+
Average Price: $9
|
88
|
+
-------------------------
|
89
|
+
ID: 2
|
90
|
+
Name: Hungry Jack's
|
91
|
+
Address: Spencer Street
|
92
|
+
Rating: 2.5
|
93
|
+
Average Price: $9.5
|
94
|
+
-------------------------
|
95
|
+
ID: 3
|
96
|
+
Name: Grill'd
|
97
|
+
Address: Southern cross station
|
98
|
+
Rating: 4
|
99
|
+
Average Price: $17
|
100
|
+
-------------------------
|
101
|
+
```
|
102
|
+
|
103
|
+
##### 3. Delete an existing entry
|
104
|
+
* The app will ask the user to select which restaurant to delete from the list (by selecting their ID).
|
105
|
+
```
|
106
|
+
Which restaurant do you want to delete from the list? Please input the ID number:
|
107
|
+
>
|
108
|
+
```
|
109
|
+
* After deleting an existing entry, the app will calculate if the list count has decreased by 1, if yes, then output a message telling users that the entry has been successfully deleted:
|
110
|
+
```
|
111
|
+
> > > > > > > > > > > > > > > > > >
|
112
|
+
The restaurant is successfully deleted!
|
113
|
+
```
|
114
|
+
##### 4. Update info
|
115
|
+
* The app will interact with users by asking which restaurant do they want to edit:
|
116
|
+
```
|
117
|
+
Which restaurant do you want to edit? Please input the ID number:
|
118
|
+
> 2
|
119
|
+
Which feature do you want to edit? Please select from name/address/rating/price:
|
120
|
+
> rating
|
121
|
+
Please input new content:
|
122
|
+
> 3
|
123
|
+
> > > > > > > > > > > > > > > > > >
|
124
|
+
The restaurant is successfully edited!
|
125
|
+
```
|
126
|
+
|
127
|
+
##### 5. Make a choice!
|
128
|
+
* Once "Make a choice" function is selected, the app will randomly select a restaurant from the current restaurants list. The restaurant will then be displayed with all the information.
|
129
|
+
|
130
|
+
|
131
|
+
### Diagram of the control flow
|
132
|
+
|
133
|
+
![avatar](docs/Plan_UML_Chart.png)
|
134
|
+
|
135
|
+
### Implementation plan
|
136
|
+
Please refer to my [Trello board][board].
|
137
|
+
|
138
|
+
[board]: https://trello.com/b/sG3Qx1Wr/dinnerchoiceterminal-app "Trello board"
|
4
139
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
140
|
|
7
141
|
## Installation
|
8
142
|
|
143
|
+
1. Install ruby:
|
144
|
+
|
145
|
+
* You need to install ruby to run this app. To verify you have ruby installed on your machine run:
|
146
|
+
```
|
147
|
+
ruby -v
|
148
|
+
```
|
149
|
+
* if you get no result from this command ruby isn't installed. There are many ways to install ruby but i recommend using rbenv.
|
150
|
+
|
151
|
+
2. ...
|
152
|
+
|
9
153
|
Add this line to your application's Gemfile:
|
10
154
|
|
11
155
|
```ruby
|
@@ -21,8 +165,11 @@ Or install it yourself as:
|
|
21
165
|
$ gem install DinnerChoice
|
22
166
|
|
23
167
|
## Usage
|
168
|
+
### Help documentation
|
24
169
|
|
25
|
-
|
170
|
+
## Tests
|
171
|
+
I used manual testing to test my app. You can find a spreadsheet in Google file:
|
172
|
+
[Test case spreadsheet](https://docs.google.com/spreadsheets/d/16QYt6_DTL253NrGNKjdTA68KubFQsKqMnZYYm90FH2g/edit?usp=sharing)
|
26
173
|
|
27
174
|
## Development
|
28
175
|
|
@@ -32,9 +179,13 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
179
|
|
33
180
|
## Contributing
|
34
181
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
36
|
-
|
182
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Lanzhou-J/DinnerChoice. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/DinnerChoice/blob/master/CODE_OF_CONDUCT.md).
|
37
183
|
|
38
184
|
## Code of Conduct
|
39
185
|
|
40
186
|
Everyone interacting in the DinnerChoice project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/DinnerChoice/blob/master/CODE_OF_CONDUCT.md).
|
187
|
+
|
188
|
+
## Reference
|
189
|
+
|
190
|
+
* Vector Illustration https://undraw.co/illustrations
|
191
|
+
* An introduction of decidophobia https://www.bustle.com/articles/157828-5-signs-you-might-have-decidophobia-or-fear-of-making-decisions
|
data/docs/.DS_Store
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require_relative '../utils/capitalize'
|
2
|
+
require_relative '../models/Restaurants'
|
3
|
+
require_relative '../utils/waiting_dot'
|
4
|
+
require_relative '../utils/dice_roller'
|
5
|
+
require_relative '../utils/error'
|
6
|
+
|
7
|
+
class Controller
|
8
|
+
def initialize(restaurant_views, restaurant_repo)
|
9
|
+
@restaurant_views = restaurant_views
|
10
|
+
@restaurant_repo = restaurant_repo
|
11
|
+
end
|
12
|
+
|
13
|
+
def index
|
14
|
+
@restaurant_views.index(@restaurant_repo.database)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create(results)
|
18
|
+
name, address, rating, average_price = capitalize(results)
|
19
|
+
count = @restaurant_repo.add(Restaurant.new(name, address, rating, average_price))
|
20
|
+
waiting()
|
21
|
+
puts
|
22
|
+
if count == 1
|
23
|
+
puts "New restaurant is successfully added!".colorize(:green)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def new
|
28
|
+
results = @restaurant_views.new
|
29
|
+
create(results)
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete_index(delete_index)
|
33
|
+
count = @restaurant_repo.delete(delete_index)
|
34
|
+
waiting()
|
35
|
+
puts
|
36
|
+
if count == -1
|
37
|
+
puts "The restaurant is successfully deleted!".colorize(:green)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def remove
|
42
|
+
if @restaurant_repo.database == []
|
43
|
+
puts
|
44
|
+
puts "List is empty, nothing to delete.".colorize(:red)
|
45
|
+
else
|
46
|
+
remove_index = @restaurant_views.delete_command
|
47
|
+
if (remove_index < 0) || (remove_index > (@restaurant_repo.database.count - 1))
|
48
|
+
error_message()
|
49
|
+
puts "Please select ID from the existing restaurants list."
|
50
|
+
else
|
51
|
+
delete_index(remove_index)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def update_info(update_index, select_item, update_content)
|
57
|
+
@restaurant_repo.update(update_index, select_item, update_content)
|
58
|
+
waiting()
|
59
|
+
puts
|
60
|
+
puts "The restaurant is successfully edited!".colorize(:green)
|
61
|
+
end
|
62
|
+
|
63
|
+
def rewrite
|
64
|
+
if @restaurant_repo.database == []
|
65
|
+
puts
|
66
|
+
puts "List is empty, nothing to update.".colorize(:red)
|
67
|
+
puts "Select 1 if you want to add a new entry."
|
68
|
+
else
|
69
|
+
update_index = @restaurant_views.update_index
|
70
|
+
|
71
|
+
if (update_index < 0) || (update_index > (@restaurant_repo.database.count - 1))
|
72
|
+
error_message()
|
73
|
+
puts "Please select ID from the existing restaurants list."
|
74
|
+
else
|
75
|
+
update_array = @restaurant_views.update_command
|
76
|
+
update_info(update_index, update_array[0], update_array[1])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def menu_list
|
82
|
+
@restaurant_views.menu_list
|
83
|
+
end
|
84
|
+
|
85
|
+
def dice
|
86
|
+
if @restaurant_repo.database == []
|
87
|
+
puts
|
88
|
+
puts "List is empty...There is nothing to choose from!".colorize(:red)
|
89
|
+
puts "Select 1 if you want to add a new entry."
|
90
|
+
else
|
91
|
+
puts
|
92
|
+
waiting()
|
93
|
+
sleep 0.5
|
94
|
+
print " ......".colorize(:green)
|
95
|
+
sleep 0.5
|
96
|
+
print "Dice rolling".colorize(:green)
|
97
|
+
sleep 0.5
|
98
|
+
puts "......".colorize(:green)
|
99
|
+
sleep 0.5
|
100
|
+
waiting()
|
101
|
+
selected_restaurant = roll_dice(@restaurant_repo.database)
|
102
|
+
@restaurant_views.index(selected_restaurant)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative "../models/Restaurants"
|
2
|
+
|
3
|
+
class RestaurantRepository
|
4
|
+
attr_reader :database
|
5
|
+
def initialize
|
6
|
+
pappaRich = Restaurant.new('Pappa Rich', 'Southern cross station, L1-CS-03', '3.5', '9')
|
7
|
+
hungryJacks = Restaurant.new('Hungry Jack\'s', 'Spencer Street', '2.5', '9.5')
|
8
|
+
grilld = Restaurant.new('Grill\'d', 'Southern cross station', '4', '17')
|
9
|
+
@database = [pappaRich, hungryJacks, grilld]
|
10
|
+
end
|
11
|
+
|
12
|
+
def add(restaurant)
|
13
|
+
length_brfore = @database.length
|
14
|
+
@database << restaurant
|
15
|
+
length_after = @database.length
|
16
|
+
count = length_after - length_brfore
|
17
|
+
return count
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(delete_input)
|
21
|
+
length_brfore = @database.length
|
22
|
+
@database.delete_at(delete_input)
|
23
|
+
length_after = @database.length
|
24
|
+
count = length_after - length_brfore
|
25
|
+
return count
|
26
|
+
end
|
27
|
+
|
28
|
+
def update(update_input, select_item, update_content)
|
29
|
+
update_restaurant = @database[update_input]
|
30
|
+
case select_item
|
31
|
+
when 'name'
|
32
|
+
update_restaurant.name = update_content
|
33
|
+
when 'address'
|
34
|
+
update_restaurant.address = update_content
|
35
|
+
when 'rating'
|
36
|
+
update_restaurant.rating = update_content
|
37
|
+
when 'price','average price'
|
38
|
+
update_restaurant.average_price = update_content
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
def heading_ascii()
|
3
|
+
puts" _____ _ _ _ ".colorize(:light_red)
|
4
|
+
puts"| __ \\(_) | | (_) ".colorize(:light_red)
|
5
|
+
puts"| | | |_ _ __ _ __ ___ _ __ ___| |__ ___ _ ___ ___ ".colorize(:light_yellow)
|
6
|
+
puts"| | | | | '_ \\| '_ \\ / _ \\ '__| / __| '_ \\ / _ \\| |/ __/ _ \\".colorize(:green)
|
7
|
+
puts"| |__| | | | | | | | | __/ | | (__| | | | (_) | | (_| __/".colorize(:aqua)
|
8
|
+
puts"|_____/|_|_| |_|_| |_|\\___|_| \\___|_| |_|\\___/|_|\\___\\___|".colorize(:light_blue)
|
9
|
+
puts
|
10
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# require_relative "../utils/menu_list"
|
2
|
+
require_relative "../utils/line_separator"
|
3
|
+
require_relative "../utils/error"
|
4
|
+
require_relative "../../DinnerChoice/controllers/DinnerChoiceController"
|
5
|
+
|
6
|
+
def menu_select(restaurant_controller)
|
7
|
+
# restaurant_controller.menu_list
|
8
|
+
user_selection = restaurant_controller.menu_list
|
9
|
+
|
10
|
+
|
11
|
+
while user_selection != '6' && user_selection != '6.'&& user_selection != 'exit'
|
12
|
+
if user_selection == '1' || user_selection == '1.'
|
13
|
+
puts 'Create a new restaurant entry:'.colorize(:green)
|
14
|
+
restaurant_controller.new
|
15
|
+
elsif user_selection == '2' || user_selection == '2.'
|
16
|
+
puts 'Display or search restaurants by key words:'.colorize(:green)
|
17
|
+
restaurant_controller.index
|
18
|
+
elsif user_selection == '3' || user_selection == '3.'
|
19
|
+
puts 'Delete an existing entry:'.colorize(:green)
|
20
|
+
restaurant_controller.remove
|
21
|
+
elsif user_selection == '4' || user_selection == '4.'
|
22
|
+
puts 'Update info of an existing entry:'.colorize(:green)
|
23
|
+
restaurant_controller.rewrite
|
24
|
+
elsif user_selection == '5' || user_selection == '5.'
|
25
|
+
puts 'Make a choice! (random generator):'.colorize(:green)
|
26
|
+
restaurant_controller.dice
|
27
|
+
else
|
28
|
+
error_message()
|
29
|
+
puts "Please select from 1 to 6, or input 'exit'."
|
30
|
+
end
|
31
|
+
line_separator()
|
32
|
+
user_selection = restaurant_controller.menu_list
|
33
|
+
end
|
34
|
+
puts 'See you next time!'
|
35
|
+
exit
|
36
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
def wine_logo()
|
3
|
+
puts
|
4
|
+
puts" _"
|
5
|
+
puts" {_}"
|
6
|
+
puts" |(|"
|
7
|
+
puts" |=|"
|
8
|
+
puts"/ \\"
|
9
|
+
puts"|.--|"
|
10
|
+
puts"|| |"
|
11
|
+
puts"|| | . ' ."
|
12
|
+
puts"|'--| ' \\~~~/"
|
13
|
+
puts"'-=-' \\~~~/ \\_/"
|
14
|
+
puts" \\_/ Y"
|
15
|
+
puts" Y _|_"
|
16
|
+
puts" _|_"
|
17
|
+
puts
|
18
|
+
end
|
data/lib/DinnerChoice/version.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative "../utils/line_separator"
|
2
|
+
|
3
|
+
class RestaurantViews
|
4
|
+
def index(restaurant_database)
|
5
|
+
puts ('-' * 25).colorize(:light_blue)
|
6
|
+
restaurant_database.each_with_index do |restaurant, index|
|
7
|
+
puts "ID: #{index + 1}"
|
8
|
+
puts "Name: #{restaurant.name}"
|
9
|
+
puts "Address: #{restaurant.address}"
|
10
|
+
puts "Rating: #{restaurant.rating}"
|
11
|
+
puts "Average Price: $#{restaurant.average_price}"
|
12
|
+
puts ('-' * 25).colorize(:light_blue)
|
13
|
+
sleep 0.1
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
puts
|
19
|
+
puts "What's the name of the restaurant you'd like to add?"
|
20
|
+
print "> "
|
21
|
+
name = gets.chomp
|
22
|
+
puts "What's the address of the restaurant you'd like to add?"
|
23
|
+
print "> "
|
24
|
+
address = gets.chomp
|
25
|
+
puts "How do you like this restaurant? please rate on a scale of 1-5, 1 being the lowest(poor), 5 being the highest(great)."
|
26
|
+
print '> '
|
27
|
+
rating = gets.chomp
|
28
|
+
puts "How much do you usually spend in this restaurant?"
|
29
|
+
print '> '
|
30
|
+
average_price = gets.chomp
|
31
|
+
puts
|
32
|
+
[name, address, rating, average_price]
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete_command
|
36
|
+
puts
|
37
|
+
puts "Which restaurant do you want to delete from the list? Please input the ID number:"
|
38
|
+
print "> "
|
39
|
+
delete_id = gets.chomp.to_i
|
40
|
+
delete_index = delete_id - 1
|
41
|
+
return delete_index
|
42
|
+
end
|
43
|
+
|
44
|
+
def update_index
|
45
|
+
puts
|
46
|
+
puts "Which restaurant do you want to edit? Please input the ID number:"
|
47
|
+
print "> "
|
48
|
+
update_id = gets.chomp.to_i
|
49
|
+
update_index = update_id - 1
|
50
|
+
end
|
51
|
+
|
52
|
+
def update_command
|
53
|
+
puts "Which feature do you want to edit? Please select from name/address/rating/price:"
|
54
|
+
print "> "
|
55
|
+
select_item = gets.chomp.downcase
|
56
|
+
puts "Please input new content:"
|
57
|
+
print "> "
|
58
|
+
update_content = gets.chomp
|
59
|
+
[select_item, update_content]
|
60
|
+
end
|
61
|
+
|
62
|
+
def menu_list()
|
63
|
+
puts 'main menu'.upcase.colorize(:light_yellow)
|
64
|
+
puts '1. Create a new restaurant entry'
|
65
|
+
puts '2. Display or search restaurants by key words'
|
66
|
+
puts '3. Delete an existing entry'
|
67
|
+
puts '4. Update info of an existing entry'
|
68
|
+
puts '5. Make a choice! (random generator)'
|
69
|
+
puts '6. Exit (or input "exit")'
|
70
|
+
puts
|
71
|
+
print 'Please select from the '
|
72
|
+
print 'MAIN MENU '.colorize(:light_yellow)
|
73
|
+
puts '(select numbers 1 to 6):'
|
74
|
+
print '> '
|
75
|
+
user_selection = gets.strip.downcase
|
76
|
+
end
|
77
|
+
end
|
data/lib/DinnerChoice.rb
CHANGED
@@ -1,8 +1,29 @@
|
|
1
|
+
# version
|
1
2
|
require_relative "DinnerChoice/version"
|
3
|
+
# heading ascii art & style
|
4
|
+
require_relative "../lib/DinnerChoice/utils/heading_ascii"
|
5
|
+
require_relative "../lib/DinnerChoice/utils/wine_logo_ascii"
|
6
|
+
require_relative "../lib/DinnerChoice/utils/line_separator"
|
2
7
|
|
3
|
-
|
8
|
+
# main menu and functions
|
9
|
+
require_relative "../lib/DinnerChoice/controllers/DinnerChoiceController"
|
10
|
+
require_relative '../lib/DinnerChoice/views/RestaurantView'
|
11
|
+
require_relative '../lib/DinnerChoice/repositories/RestaurantRepository'
|
12
|
+
require_relative "../lib/DinnerChoice/utils/menu_select"
|
4
13
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
14
|
+
heading_ascii()
|
15
|
+
sleep 0.5
|
16
|
+
puts "What restaurants do you recommend for lunch/dinner?".colorize(:light_green)
|
17
|
+
sleep 0.3
|
18
|
+
puts "Please select!".colorize(:light_blue)
|
19
|
+
sleep 0.3
|
20
|
+
wine_logo()
|
21
|
+
sleep 0.3
|
22
|
+
|
23
|
+
restaurant_view = RestaurantViews.new
|
24
|
+
restaurant_repository = RestaurantRepository.new
|
25
|
+
restaurant_controller = Controller.new(restaurant_view, restaurant_repository)
|
26
|
+
|
27
|
+
puts
|
28
|
+
line_separator()
|
29
|
+
menu_select(restaurant_controller)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: DinnerChoice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lanzhou Jiang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -43,9 +43,26 @@ files:
|
|
43
43
|
- Rakefile
|
44
44
|
- bin/console
|
45
45
|
- bin/setup
|
46
|
+
- docs/.DS_Store
|
47
|
+
- docs/Activity_Diagram.png
|
48
|
+
- docs/Ascii_art_banner.png
|
49
|
+
- docs/Dinner_choice.png
|
50
|
+
- docs/Plan_UML_Chart.png
|
46
51
|
- lib/.DS_Store
|
47
52
|
- lib/DinnerChoice.rb
|
53
|
+
- lib/DinnerChoice/controllers/DinnerChoiceController.rb
|
54
|
+
- lib/DinnerChoice/models/Restaurants.rb
|
55
|
+
- lib/DinnerChoice/repositories/RestaurantRepository.rb
|
56
|
+
- lib/DinnerChoice/utils/capitalize.rb
|
57
|
+
- lib/DinnerChoice/utils/dice_roller.rb
|
58
|
+
- lib/DinnerChoice/utils/error.rb
|
59
|
+
- lib/DinnerChoice/utils/heading_ascii.rb
|
60
|
+
- lib/DinnerChoice/utils/line_separator.rb
|
61
|
+
- lib/DinnerChoice/utils/menu_select.rb
|
62
|
+
- lib/DinnerChoice/utils/waiting_dot.rb
|
63
|
+
- lib/DinnerChoice/utils/wine_logo_ascii.rb
|
48
64
|
- lib/DinnerChoice/version.rb
|
65
|
+
- lib/DinnerChoice/views/RestaurantView.rb
|
49
66
|
homepage: https://github.com/Lanzhou-J/DinnerChoice/blob/master/lib/DinnerChoice.rb
|
50
67
|
licenses:
|
51
68
|
- MIT
|