Class: RebelLegion::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_categoryObject

Returns the value of attribute current_category.



2
3
4
# File 'lib/rebel_legion/cli.rb', line 2

def current_category
  @current_category
end

#current_category_numberObject

Returns the value of attribute current_category_number.



2
3
4
# File 'lib/rebel_legion/cli.rb', line 2

def current_category_number
  @current_category_number
end

Instance Method Details

#callObject



4
5
6
7
8
9
10
11
# File 'lib/rebel_legion/cli.rb', line 4

def call
  RebelLegion::Scraper.new
  #  would be nice to have a loading bar here...
  input = nil
  welcome
  view_category_list
  goodbye
end

#goodbyeObject



56
57
58
# File 'lib/rebel_legion/cli.rb', line 56

def goodbye
  puts "May the Force be with you...always.".colorize(:red)
end

#view_category_listObject



18
19
20
21
22
23
# File 'lib/rebel_legion/cli.rb', line 18

def view_category_list
  puts "Select a category of costumes to view by entering a number, or type 'exit':".colorize(:light_red)
  RebelLegion::CostumeCategory.display_all_names
  input = gets.strip
  view_costume_list(input.to_i - 1) if input != "exit"
end

#view_costume_details(number) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rebel_legion/cli.rb', line 41

def view_costume_details(number)
  @current_category.costumes[number].view_details
  puts "To go back, enter 'back'.".colorize(:light_red)
  puts "To return to the main menu, enter 'main'. Or, type 'exit'.".colorize(:light_red)
  input = gets.strip
  unless input == "exit"
    case input
    when "back"
      view_costume_list(@current_category_number)
    when "main"
      view_category_list
    end
  end
end

#view_costume_list(number) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rebel_legion/cli.rb', line 25

def view_costume_list(number)
  @current_category_number = number
  @current_category = RebelLegion::CostumeCategory.all[number]
  current_category.display_costume_names
  puts "To view a costume's standards for Rebel Legion membership, enter its number.".colorize(:light_red)
  puts "To return to the main menu, enter 'main'. Or, type 'exit'.".colorize(:light_red)
  input = gets.strip
  unless input == "exit"
    if input == "main"
      view_category_list
    else
      view_costume_details(input.to_i - 1)
    end
  end
end

#welcomeObject



13
14
15
16
# File 'lib/rebel_legion/cli.rb', line 13

def welcome
  puts "THE REBEL LEGION: An International Star Wars Costuming Organization!".colorize(:red)
  puts "Welcome to the Rebel Legion Costume Standards Viewer."
end