ShopInventory 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/shop.rb +130 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 502a8d1fa3a43aa9d9af6bba69635c2b0f4c9f9f
4
+ data.tar.gz: 8cb1fcdef2798f18a5ceaa42c09475c906b8e744
5
+ SHA512:
6
+ metadata.gz: 93bfb40b626b8f6edaaae4632590a21df3734ec5e3f2d4ec7da7014d0ccb3df9f8ac5968cdc735bd7cdbc8c46979e684ad57351d1d07db78a4cacdf2e0f43972
7
+ data.tar.gz: de0a403b62adb202cb0a749eda03504c547b850b7c2ab11c5f741e2fb42756040929b03befcd90e456ab44e9458f3ca41ef451915430737a6d0cbadbb530cfd0
data/shop.rb ADDED
@@ -0,0 +1,130 @@
1
+ class Methods
2
+ @choice="y"
3
+
4
+ def add_product
5
+ while @choice!="N"
6
+ puts "Enter product name"
7
+ product_name=gets.chomp
8
+
9
+ puts "Enter product price"
10
+ product_price=gets.chomp
11
+
12
+ puts "Enter product company name"
13
+ company_name=gets.chomp
14
+
15
+ puts "Enter stock item"
16
+ stock_item=gets.chomp
17
+
18
+ f=File.open('inventory','a+')
19
+
20
+ f.puts "#{product_name} #{product_price} #{company_name} #{stock_item}"
21
+
22
+ f.close
23
+ puts "do you want to continue or not??y/n"
24
+ @choice=gets.chomp
25
+ end
26
+ end
27
+
28
+
29
+ def display_product
30
+ f=File.open("inventory","r")
31
+ f.each_line do |line|
32
+ puts line
33
+ end
34
+ f.close
35
+ end
36
+
37
+
38
+
39
+ def search_product
40
+ puts"enter product name that you want to search"
41
+ product_search=gets.chomp
42
+ end
43
+
44
+ def remove_product
45
+ puts"enter product name that you want to remove"
46
+ remove=gets.chomp
47
+
48
+ file_contents=File.read("inventory")
49
+
50
+ removed_product=file_contents.gsub(/#{remove}\s\w+\s\w+\s\w+/," ")
51
+ puts removed_product
52
+ f=File.open("inventory", "w") { |file| file.puts removed_product }
53
+ end
54
+
55
+ def buy_product
56
+
57
+ puts "Enter product name"
58
+ product_nm=gets.chomp
59
+
60
+ puts "Enter credit card info"
61
+ credit_info=gets.chomp
62
+
63
+ f=File.open('orders','a+')
64
+
65
+ f.puts "#{product_nm} #{credit_info}"
66
+ f.close
67
+
68
+ end
69
+
70
+
71
+ end
72
+ class Shop < Methods
73
+
74
+ puts "This is the inventory shop"
75
+ puts "Who are you customer or shopkeeper 1:customer 2:shopkeeper"
76
+ option=gets.chomp
77
+
78
+ case option
79
+ when "1"
80
+ puts "you are customer"
81
+ puts "Enter operations you want to perform a.List b.search c.buy"
82
+ userip=gets.chomp
83
+ case userip
84
+ when "a"
85
+ puts "You are listing data"
86
+ addobj = Methods.new
87
+ addobj.display_product
88
+
89
+ when "b"
90
+ puts "You are searching data"
91
+
92
+ when "c"
93
+ puts "You are buying data"
94
+ buyobj=Methods.new
95
+ buyobj.buy_product
96
+ else
97
+ puts "default"
98
+ end
99
+
100
+ when "2"
101
+ puts "you are shopkeeper"
102
+ puts "Enter operations you want to perform a.Add product b.search c.edit product d.list product"
103
+ keeperip=gets.chomp
104
+ case keeperip
105
+ when "a"
106
+ puts "You are adding data"
107
+ addobj = Methods.new
108
+ addobj.add_product
109
+
110
+ when "b"
111
+ puts "You are searching data"
112
+
113
+ when "c"
114
+ puts "You are removing data"
115
+ removeobj=Methods.new
116
+ removeobj.remove_product
117
+
118
+ when "d"
119
+ dispobj = Methods.new
120
+ dispobj.display_product
121
+ else
122
+ puts "default"
123
+ end
124
+
125
+ else
126
+ puts "sorry u can not be the part of our service"
127
+ end
128
+ end
129
+
130
+
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ShopInventory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ashvini Bhosale
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-25 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - ashumbhosale@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - shop.rb
21
+ homepage:
22
+ licenses: []
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.4.3
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: I have this shop and I managing it.
44
+ test_files: []