You are going to create a simple Sinatra application that looks up Stock Exchange prices and returns the price to the user.
- Create a one page Sinatra app (just one route to "/").
- Use HTML and CSS to customise the layout.
- Add a form with a field for the stock symbol, and a button to submit.
- After the form is submitted, display to the user the stock symbol and the current price (retrieved from the internet using a Ruby gem -- you'll need to find one).
Some example stock symbols are:
Symbol | Company | Example Price |
---|---|---|
AAPL | Apple | 116.47 |
GOOG | 537.5 | |
AMZN | Amazon | 332.63 |
MSFT | Microsoft | 47.98 |
CAKE | Cheesecake Factory Inc | 47.27 |
FIZZ | National Beverage Corp. | 25.55 |
TSLA | Tesla Motors | 242.78 |
GPRO | GoPro Inc. | 70.72 |
# terminal
gem install yahoofinance
# ruby
require 'yahoofinance'
def get_standard_quotes(symbol)
YahooFinance::get_standard_quotes(symbol)[symbol] rescue nil
end
stock = get_standard_quotes("aapl")