Class: SellerAPI
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#money ⇒ Object
Returns the value of attribute money.
-
#name ⇒ Object
Returns the value of attribute name.
-
#valid_hash ⇒ Object
Returns the value of attribute valid_hash.
Class Method Summary collapse
Methods included from UserModule
get_number, get_string, list_products, search_product
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/SellerAPI.rb', line 8 def id @id end |
#money ⇒ Object
Returns the value of attribute money.
8 9 10 |
# File 'lib/SellerAPI.rb', line 8 def money @money end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/SellerAPI.rb', line 8 def name @name end |
#valid_hash ⇒ Object
Returns the value of attribute valid_hash.
8 9 10 |
# File 'lib/SellerAPI.rb', line 8 def valid_hash @valid_hash end |
Class Method Details
.add_product ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/SellerAPI.rb', line 12 def self.add_product puts "Enter product details: ('q' to quit )" name = get_string($PRODUCT_FIELD[:name]) return if name == -1 color = get_string($PRODUCT_FIELD[:color]) return if color == -1 price = get_number($PRODUCT_FIELD[:price]) return if price == -1 quantity = get_number($PRODUCT_FIELD[:quantity]) return if quantity == -1 product = {name: name, color: color, price: price, quantity: quantity} ProductAPI.add(product) end |
.delete_product ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/SellerAPI.rb', line 42 def self.delete_product list_products print "\n\tEnter product id to be deleted ('q' to quit): " id = gets.chomp.to_i return if id == -1 ProductAPI.delete(id) end |
.update_product ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/SellerAPI.rb', line 28 def self.update_product list_products puts "\n\tEnter the product needed to be updated: ('q' to quit) " id = get_number("ID of product") return if id == -1 key = get_string("Update field ") return if key == -1 value = get_string("New value for '#{key}'") return if id == -1 ProductAPI.update(id, key.to_sym, value) end |