Class: QuickTicker::MainCli

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

Instance Attribute Summary collapse

Attributes inherited from Cli

#exit_message, #last_option_lambda, #scraper, #stock

Instance Method Summary collapse

Methods inherited from Cli

#call_stock_option_menu, #display_stock_description, #display_stock_header, #display_stock_option_menu, #display_stock_quote, #display_stock_related_companies, #fetch_stock_description, #fetch_stock_quote, #fetch_stock_related_companies, #process_stock_option_menu_input, #welcome

Constructor Details

#initialize(cli = nil) ⇒ MainCli

Returns a new instance of MainCli.



7
8
9
10
11
12
# File 'lib/main_cli.rb', line 7

def initialize(cli = nil)
	super(cli)
	self.dev = QuickTicker::DevCli.new(self)
	self.last_option_lambda = -> { self.ticker_symbol_prompt }
	self.exit_message = "Thank you for using Quick Ticker!"
end

Instance Attribute Details

#devObject

Returns the value of attribute dev.



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

def dev
  @dev
end

Instance Method Details

#symbol_validation(symbol, fixture_url = nil) ⇒ Object



28
29
30
# File 'lib/main_cli.rb', line 28

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

#ticker_symbol_promptObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/main_cli.rb', line 15

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