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



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

def goodbye
  puts 'Goodbye and good luck!'
end


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 14

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' - refresh trending stocks."
    input = gets.strip.downcase
    if input == 'trending'
      trending_tickers
    elsif StockInfo::Stock.check_symbol(input.upcase) == true
      stock = StockInfo::Stock.create_or_return(input.upcase)
      stock.print_info
      puts 'View recent news articles related to this stock? (yes/no)'
      news_bool = gets.strip[0].downcase
      input = StockInfo::News.news_menu(stock) if news_bool == 'y'
    elsif input != 'exit'
      puts 'Please input a command or ticker symbol'
    end
  end
end


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

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