lib/stock-gains/cli.rb in stock-gains-0.1.7 vs lib/stock-gains/cli.rb in stock-gains-0.1.8
- old
+ new
@@ -1,27 +1,33 @@
module StockGains
class StockGains::CLI
def call
- StockGains::Portfolio.new.call
- start
+ begin
+ StockGains::Portfolio.new.call
+ start
+ rescue
+ puts "\n\nTo upload your portfolio to Stock Gains, see installation at:"
+ puts "https://github.com/frankNowinski/stock-gains\n\n"
+ stock_lookup
+ end
+ puts "\nGoodbye!"
end
def start
input = ""
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 "the stock name in your portfolio or enter 'all' to display all."
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.downcase.scan(/\w+/)
end until valid_input?(input) || input.first == "e"
if input.first != "e"
input.first == "all" ? find_all : find(input)
stock_lookup
end
- puts "\nGoodbye!"
end
def valid_input?(input)
input.first == "all" || input.map(&:to_i).all?{ |n| n.between?(1, StockGains::Stock.all.count)}
end
\ No newline at end of file