【发布时间】:2011-06-03 04:02:09
【问题描述】:
这是我正在使用的代码:
class Trader
def initialize(ticker ="GLD")
@ticker = ticker
end
def yahoo_data(days=12)
require 'yahoofinance'
YahooFinance::get_historical_quotes_days( @ticker, days ) do |row|
puts "#{row.join(',')}" # this is where a solution is required
end
end
end
yahoo_data 方法从 Yahoo Finance 获取数据并将价格历史记录放在控制台上。但是,您将如何使用前面的代码来填充一个以后可以作为对象操作的数组,而不是一个简单的 put 蒸发到以太中。
类似于:
do |row| populate_an_array_method(row.join(',') end
【问题讨论】: