From nas-yahoo_stock
I would like to get the user's input from the command-line, and pass it as an argument, which returns the stock quote.
require 'rubygems'
require 'yahoo_stock'
print "St开发者_开发技巧ock Symbol: "
symbol = gets
quote = YahooStock::Quote.new(:stock_symbols => ['YHOO', "symbol"])
puts quote.results.output
When I input "YHOO" at the command-line the output returned is "3/10/2011",17.08 (which is great) and "N/A",0.00 (not so great), respectively. Obviously I missed something simple. I tried @symbol with no luck, and I can't find any related answers.
Thanks for your help.
Take the quotes off of "symbol"
精彩评论