Class: MobiStore
- Inherits:
-
Object
- Object
- MobiStore
- Defined in:
- lib/mobistore.rb
Class Method Summary collapse
Class Method Details
.get_logo ⇒ Object
8 9 10 11 12 |
# File 'lib/mobistore.rb', line 8 def self.get_logo "\n\t\t\t________________\n" + "\t\t\t[The Mobi Store]" + "\n\n\n" end |
.init ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/mobistore.rb', line 73 def self.init ProductAPI.seed TranscationAPI.seed system 'clear' print "#{get_logo}\tWhich type of user are you? 'Buyer'(b) | 'Seller'(s) | 'quit'(q) : " choice = gets.chomp.downcase if choice == "buyer" || choice == "b" elsif choice == "seller" || choice == "s" elsif choice == "quit" || choice == "q" return else puts "Invalid input, try again?" return init end end |
.show_buyer_options ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/mobistore.rb', line 46 def self. system 'clear' loop do print "#{get_logo}\tEnter your option:\n\t " + "'#{$BUYER_OPTIONS[:list]}' | " + "'#{$BUYER_OPTIONS[:search]}'| " + "'#{$BUYER_OPTIONS[:buy]}' | " + "'quit' (q) : " choice = gets.chomp.downcase if choice == $BUYER_OPTIONS[:list] BuyerAPI.list_products elsif choice == $BUYER_OPTIONS[:search] BuyerAPI.search_product elsif choice == $BUYER_OPTIONS[:buy] BuyerAPI.list_products BuyerAPI.buy elsif choice == "quit" || choice == 'q' break else puts "Woops, invalid input. Can you enter again?" end end end |
.show_seller_options ⇒ Object
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 |
# File 'lib/mobistore.rb', line 14 def self. system 'clear' loop do print "#{get_logo}\tEnter your option:\n\t " + "'#{$SELLER_OPTIONS[:list]}' | " + "'#{$SELLER_OPTIONS[:search]}'| " + "'#{$SELLER_OPTIONS[:add]}' | " + "'#{$SELLER_OPTIONS[:update]}'| " + "'#{$SELLER_OPTIONS[:update]}'| " + "'quit' (q) : " choice = gets.chomp.downcase if choice == $SELLER_OPTIONS[:list] SellerAPI.list_products elsif choice == $SELLER_OPTIONS[:search] SellerAPI.search_product elsif choice == $SELLER_OPTIONS[:add] SellerAPI.add_product elsif choice == $SELLER_OPTIONS[:update] SellerAPI.update_product elsif choice == $SELLER_OPTIONS[:delete] SellerAPI.delete_product elsif choice == "quit" || choice == 'q' break else puts "Woops, invalid input. Can you enter again?" end end end |