开发者

Pass User input as argument in Ruby

开发者 https://www.devze.com 2023-02-16 15:11 出处:网络
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.

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"

0

精彩评论

暂无评论...
验证码 换一张
取 消