class DodgePackages::CLI
Attributes
package[R]
Public Instance Methods
call()
click to toggle source
# File lib/dodge_packages/cli.rb, line 3 def call #runs the program clear_page puts "Welcome to the Dodge Packages Program!" pick_car end
challenger_listing()
click to toggle source
# File lib/dodge_packages/cli.rb, line 9 def challenger_listing # lists the packages @packages = DodgePackages::Package.challenger_available @packages.each.with_index(1) do |package, i| puts "#{i}. #{package.name}" end end
charger_listing()
click to toggle source
# File lib/dodge_packages/cli.rb, line 16 def charger_listing # lists the packages @packages = DodgePackages::Package.charger_available @packages.each.with_index(1) do |package, i| puts "#{i}. #{package.name}" end end
clear_page()
click to toggle source
# File lib/dodge_packages/cli.rb, line 65 def clear_page system "clear" end
end_program()
click to toggle source
# File lib/dodge_packages/cli.rb, line 74 def end_program #ends program puts "Thanks for considering Dodge!" end
pick_car()
click to toggle source
# File lib/dodge_packages/cli.rb, line 23 def pick_car # picks a vehicle puts "Enter a number to select a vehicle to see packages for or type exit to close the program." DodgePackages::Package.car_names input = nil while input != "exit" input = gets.strip.downcase if input == "1" puts "loading.." split_line challenger_listing selection elsif input == "2" puts "loading.." split_line charger_listing selection elsif input == "exit" end_program exit else puts "Please enter a valid option." end end end
selection()
click to toggle source
# File lib/dodge_packages/cli.rb, line 47 def selection #makes a package selection input = nil while input != "exit" puts "-------------------------------------------" puts "Enter a number corresponding to a package to view it's features or type exit to close the program." input = gets.strip.downcase if input.to_i > 0 && input.to_i <= 3 && !input.include?(".") a_package = @packages[input.to_i-1] puts "#{a_package.features}" elsif input == "exit" end_program exit else puts "Please enter a valid option." end end end
split_line()
click to toggle source
# File lib/dodge_packages/cli.rb, line 69 def split_line puts "-------------------------------------------" puts "-------------------------------------------" end