lib/stock-gains/cli.rb in stock-gains-0.1.6 vs lib/stock-gains/cli.rb in stock-gains-0.1.7
- old
+ new
@@ -11,14 +11,14 @@
begin
puts "\nTo view more stock information, enter the number associated with"
puts "the stock or enter 'all' to view all of the stocks in your portfolio."
puts "Separate digits with a space to view multiple stocks."
puts "(Enter 'e' at anytime throughout the program to exit)\n\n"
- input = gets.strip.scan(/\w+/)
+ input = gets.strip.downcase.scan(/\w+/)
end until valid_input?(input) || input.first == "e"
- if input.first != "e"
+ if input.first != "e"
input.first == "all" ? find_all : find(input)
stock_lookup
end
puts "\nGoodbye!"
end
@@ -29,11 +29,11 @@
def find_all
print_stock_info(StockGains::Stock.all)
end
- def find(stock)
- print_stock_info(stock.map(&:to_i).collect{ |s| StockGains::Stock.all[s-1] })
+ def find(input)
+ print_stock_info(input.map(&:to_i).collect{ |s| StockGains::Stock.all[s-1] })
end
def print_stock_info(stocks)
puts "\n"
stocks.each do |s|
\ No newline at end of file