Class: StockInfo::CLI

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

Overview

Our CLI controller

Instance Method Summary collapse

Instance Method Details

#callObject



3
4
5
6
7
# File 'lib/stock_info/cli.rb', line 3

def call        
    trending_tickers
    menu
    goodbye
end

#goodbyeObject



33
34
35
# File 'lib/stock_info/cli.rb', line 33

def goodbye
    puts "Goodbye and good luck!"
end


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/stock_info/cli.rb', line 12

def menu
    input = nil
    while input != 'exit'
        puts "Enter the ticker symbol of a stock you would like more info on."
        puts "Other commands: 'exit' - exits stock-info, 'trending' - shows trending stocks."
        input = gets.strip.downcase
        if input == 'trending'
            trending_tickers
        elsif StockInfo::Stock.check_symbol(input.upcase) == true
            stock = StockInfo::Stock.new(input.upcase)
            stock.print_info
            puts "View recent news articles related to this stock? (yes/no)"
            news_bool = gets.strip[0].downcase
            if news_bool == 'y'
                StockInfo::Stock::News.news_menu(stock)
            end
        elsif input != 'exit'
            puts 'Please input a command or ticker symbol'
        end
    end
end


8
9
10
11
# File 'lib/stock_info/cli.rb', line 8

def trending_tickers
    puts "Loading today's trending stocks..."
    StockInfo::Stock.print_trending
end