This repository has been archived by the owner on Jun 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathapp.rb
133 lines (130 loc) · 3.59 KB
/
app.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
require_relative 'lib/analyzable'
require_relative 'lib/product'
require_relative 'data/schema'
include Analyzable
# Uncomment the following code once ALL your tests have passed!
# db_create
#
# puts "-------------------"
# puts "RETURN ALL PRODUCTS"
# puts "-------------------"
# print Product.all
# puts
# puts "-----------------"
# puts "CREATE PRODUCTS"
# puts "-----------------"
# print Product.create(brand: "Udacity", name: "yoyo", price: 10.00)
# print Product.create(brand: "Bouncy", name: "ball", price: 12.00)
# print Product.create(brand: "MyCool", name: "dollhouse", price: 14.40)
# print Product.create(brand: "MySoft", name: "stuffed animal", price: 2.09)
# print Product.create(brand: "AllMy", name: "yoyo", price: 1.00)
# print Product.create(brand: "Udacity", name: "doll", price: 5.99)
#
# puts "-------------------"
# puts "RETURN ALL PRODUCTS"
# puts "-------------------"
# print Product.all
#
# puts "--------------------------------------------------------------"
# puts "TEST ERROR HANDLING FOR DELETE - COMMENT OUT BEFORE SUBMITTING"
# puts "--------------------------------------------------------------"
# print Product.destroy(1000000000000)
#
# puts "------------------------------------------------------------"
# puts "TEST ERROR HANDLING FOR FIND - COMMENT OUT BEFORE SUBMITTING"
# puts "------------------------------------------------------------"
# print Product.find(1000000000000)
#
# puts
# puts "--------------------"
# puts "RETURN FIRST PRODUCT"
# puts "--------------------"
# print Product.first
#
#
# puts
# puts "-----------------------"
# puts "RETURN FIRST 2 PRODUCTS"
# puts "-----------------------"
# print Product.first(2)
#
# puts
# puts "-------------------"
# puts "RETURN LAST PRODUCT"
# puts "-------------------"
# print Product.last
#
# puts
# puts "----------------------"
# puts "RETURN LAST 2 PRODUCTS"
# puts "----------------------"
# print Product.last(2)
#
# puts
# puts "-------------------------"
# puts "DESTROY PRODUCT WITH ID 2"
# puts "-------------------------"
# print Product.destroy(2)
#
# puts
# puts "-------------------------------"
# puts "FIND PRODUCT 4 AND UPDATE BRAND"
# puts "-------------------------------"
# print Product.find(4).update(brand: "NewBrand")
#
# puts
# puts "--------------"
# puts "FIND PRODUCT 1"
# puts "--------------"
# print Product.find(1)
#
# puts
# puts "-----------------"
# puts "DESTROY PRODUCT 3"
# puts "-----------------"
# print Product.destroy(3)
#
# puts
# puts "-------------------------------"
# puts "RETURN PRODUCTS WITH BRAND UDACITY"
# puts "-------------------------------"
# print Product.where(brand: "Udacity")
#
# puts
# puts "-------------------------------------"
# puts "RETURN FIRST PRODUCT WITH GIVEN BRAND"
# puts "-------------------------------------"
# print Product.find_by_brand("Udacity")
# puts
#
# puts
# puts "------------------------------------"
# puts "RETURN FIRST PRODUCT WITH GIVEN NAME"
# puts "------------------------------------"
# print Product.find_by_name("yoyo")
# puts
#
# puts
# puts "----------------------------"
# puts "RETURN HASH WITH NAME COUNTS"
# puts "----------------------------"
# print Analyzable::count_by_name(Product.all)
#
# puts
# puts "----------------------------"
# puts "RETURN HASH WITH BRAND COUNTS"
# puts "----------------------------"
# print Analyzable::count_by_brand(Product.all)
#
# puts
# puts "--------------------"
# puts "RETURN AVERAGE PRICE"
# puts "--------------------"
# print Analyzable::average_price(Product.all)
#
# puts
# puts "--------------------"
# puts "PRINT SUMMARY REPORT"
# puts "--------------------"
# print Analyzable::print_report(Product.all)
# puts