First of all, I am using this gemfile here :
https://github.com/ryanwkan/covetous
After initializing
my_profile = Covetous::Profile::Career.new ‘rwk#1242’
I get an array like this
When I try to access it like this
my_profile.heroes, it returns
[{"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}]
and if i go 1 step ahead and use my_profile.heroes[0] it returns
{"name"=>"Ziyi", "id"=>10692899, "level"=>60, "hardcore"=>false, "paragonLevel"=>87, "gender"=>1, "dead"=>false, "class"=>"wizard", "last-updated"=>1354337248}
However, I can’t access further data from the above result.
my_profile.heroes[0].name returns NoMethodError and my_profile.heroes[0][0] returns “nil”
Am I doing it wrong?
Thanks in advance
Ryan
It’s a hash; use hash syntax:
Unless something wraps up a hash with accessor methods, it’s just a hash.