-
Notifications
You must be signed in to change notification settings - Fork 1
/
handler.rb
91 lines (80 loc) · 1.89 KB
/
handler.rb
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require_relative 'app'
class Handler
def initialize
@app = App.new
end
def options
@app.options
end
def capture_item_info
print 'Enter Genre: '
genre_name = gets.chomp
print 'Enter Author first name: '
author_first_name = gets.chomp
print 'Enter Author last name: '
author_last_name = gets.chomp
print 'Label title : '
label_title = gets.chomp
print 'Label Color: '
label_color = gets.chomp
print 'publish_date in DD/MM/YY format: '
publish_date = gets.chomp
[genre_name, author_first_name, author_last_name, label_title, label_color, publish_date]
end
def create_book
data = capture_item_info
print 'Enter publisher of the book: '
publisher = gets.chomp
print 'cover_state: '
cover_state = gets.chomp
@app.new_book(publisher, cover_state, data)
end
def all_books
@app.all_books
end
def all_labels
@app.all_labels
end
def create_musicalbum
data = capture_item_info
print 'Is the Music Album on Spotify? [Y/N]: '
result = gets.chomp.downcase
if result == 'y'
on_spotify = true
elsif result == 'n'
on_spotify = false
else
puts 'Invalid input'
puts 'Enter a Menu option: '
end
@app.new_musicalbum(on_spotify, data)
end
def list_musicalbums
@app.list_musicalbums
end
def all_genres
@app.list_genres
end
def create_game
data = capture_item_info
print 'Is the Game multiplayer? [Y/N]: '
result = gets.chomp.downcase
if result == 'y'
multiplayer = true
elsif result == 'n'
multiplayer = false
else
puts 'Invalid input'
puts 'Enter a Menu option: '
end
print 'Enter the last played date (DD/MM/YY): '
last_played_at = gets.chomp
@app.new_game(multiplayer, last_played_at, data)
end
def all_games
@app.list_games
end
def all_authors
@app.list_authors
end
end