Class: MobiStore

Inherits:
Object
  • Object
show all
Defined in:
lib/mobistore.rb

Class Method Summary collapse

Class Method Details

.get_logoObject



8
9
10
11
12
# File 'lib/mobistore.rb', line 8

def self.
  "\n\t\t\t________________\n"  +
  "\t\t\t[The Mobi Store]"      +
  "\n\n\n"
end

.initObject



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"
    show_buyer_options
  elsif choice == "seller" || choice == "s"
    show_seller_options
  elsif choice == "quit" || choice == "q"
    return
  else
    puts "Invalid input, try again?"
    return init
  end
end

.show_buyer_optionsObject



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.show_buyer_options
  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_optionsObject



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.show_seller_options
  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