class StockGains::StockLookup

Attributes

tickers[RW]

Public Class Methods

new() click to toggle source
# File lib/stock-gains/stock_lookup.rb, line 4
def initialize
  @tickers = []
end

Public Instance Methods

call() click to toggle source
# File lib/stock-gains/stock_lookup.rb, line 8
def call
  input = "" 
  loop do
    puts "Enter the stock ticker(s) of any stock you would like to view."
    puts "Separate stock tickers with a space.\n\n"
    input = gets.strip.downcase
    break if input == "e" || input == ""
    tickers << input.strip.scan(/\S[a-zA-Z]+/).join("+").upcase
    StockGains::CLI.new.print_stock_info(retrieve_stock_info(tickers))
    tickers.clear
  end
end
retrieve_stock_info(tickers) click to toggle source
# File lib/stock-gains/stock_lookup.rb, line 21
def retrieve_stock_info(tickers)
  StockGains::Stock.retrieve_stock(tickers).collect do |s|
    StockGains::Stock.new(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9])
  end
end