首先,我在这里使用这个 gemfile:
https://github.com/ryanwkan/covetous
初始化后
my_profile = Covetous::Profile::Career.new 'rwk#1242'
我得到一个这样的数组
当我尝试像这样访问它时
my_profile.heroes,它返回
[{"name"=>"Ziyi", "id"=>10692899, "level"=>60, "hardcore"=>false, "paragonLevel"=>87, "gender"=>1, "dead"=>false, "class"=>"wizard", "last-updated"=>1354337248}, {"name"=>"Aerendil", "id"=>5987778, "level"=>60, "hardcore"=>false, "paragonLevel"=>0, "gender"=>1, "dead"=>false, "class"=>"demon-hunter", "last-updated"=>1353389408}, {"name"=>"Bubba", "id"=>9177617, "level"=>60, "hardcore"=>false, "paragonLevel"=>11, "gender"=>0, "dead"=>false, "class"=>"witch-doctor", "last-updated"=>1352946041}, {"name"=>"Emma", "id"=>7153459, "level"=>60, "hardcore"=>false, "paragonLevel"=>0, "gender"=>1, "dead"=>false, "class"=>"monk", "last-updated"=>1347863170}, {"name"=>"Grumbar", "id"=>17793743, "level"=>60, "hardcore"=>false, "paragonLevel"=>0, "gender"=>0, "dead"=>false, "class"=>"barbarian", "last-updated"=>1352944313}, {"name"=>"BankerOne", "id"=>12215739, "level"=>1, "hardcore"=>false, "paragonLevel"=>0, "gender"=>1, "dead"=>false, "class"=>"monk", "last-updated"=>1351810350}]
如果我提前 1 步使用 my_profile.heroes[0] 它会返回
{"name"=>"Ziyi", "id"=>10692899, "level"=>60, "hardcore"=>false, "paragonLevel"=>87, "gender"=>1, "dead"=>false, "class"=>"wizard", "last-updated"=>1354337248}
但是,我无法从上述结果中访问更多数据。
my_profile.heroes[0].name 返回 NoMethodError 并且 my_profile.heroes[0][0] 返回“nil”
我做错了吗?
提前致谢
瑞安