Class: MainCli

Inherits:
Cli
  • Object
show all
Defined in:
lib/main_cli.rb

Instance Attribute Summary collapse

Attributes inherited from Cli

#stock

Instance Method Summary collapse

Methods inherited from Cli

#display_desc, #display_quote, #welcome

Constructor Details

#initialize(cli = nil) ⇒ MainCli

Returns a new instance of MainCli.



5
6
7
8
# File 'lib/main_cli.rb', line 5

def initialize(cli = nil)
  super(cli)
  self.dev = DevCli.new(self)
end

Instance Attribute Details

#devObject

Returns the value of attribute dev.



3
4
5
# File 'lib/main_cli.rb', line 3

def dev
  @dev
end

#scraperObject

Returns the value of attribute scraper.



3
4
5
# File 'lib/main_cli.rb', line 3

def scraper
  @scraper
end

Instance Method Details

#stock_option_menu(opt_1_string, opt_1_lambda) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/main_cli.rb', line 24

def stock_option_menu(opt_1_string, opt_1_lambda)
  input = super(opt_1_string, opt_1_lambda)
  if input == "1"
    opt_1_lambda.()
  elsif input == "2"
    self.ticker_symbol_prompt
  else
    return nil
  end
end

#symbol_validation(symbol, valid, fixture_url = nil) ⇒ Object



35
36
37
# File 'lib/main_cli.rb', line 35

def symbol_validation(symbol, valid, fixture_url = nil)
  super(symbol, valid)[0] # returns whether entered symbol was valid
end

#ticker_symbol_promptObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/main_cli.rb', line 11

def ticker_symbol_prompt
  valid = false
  while !valid do
    print "\nPlease enter a ticker symbol: "
    symbol = gets.strip.upcase
    if symbol == "DEV"
      self.welcome("Developer Mode", -> {self.dev.option_menu}) if symbol == "DEV"
    else
      valid = self.symbol_validation(symbol, valid)
    end
  end
end