メソッドでフォロワーの数のみを返すようにします。最後の「if」ステートメントに進まない場合、前のコードからクエリまたはハッシュを返すだけであることがわかりました。
def my_twitter_followers
if JSON.parse(contact_hash)["social_profiles"]
JSON.parse(contact_hash)["social_profiles"].each do |profile|
if profile["followers"]
return profile["followers"]
end
end
end
end
ハッシュを含む social_profiles 配列内に Twitter プロファイルが存在する場合、フォロワーを返すようにしたい (したがって、次の ["followers"]
[{"url"=>" http://gravatar.com/xxxxxx ", "id"=>"xxxxxx", "type"=>"gravatar", "type_id"=>"gravatar", "type_name"= >"Gravatar", "username"=>"xxxxxxx", "bio"=>"SOME LARGE BIO"}, {"url"=>" http://www.facebook.com/xxxxxxx ", "type"= >"facebook", "type_id"=>"facebook", "type_name"=>"Facebook", "ユーザー名"=>"xxxxxx", "id"=>"xxxxxx"}, {"url"=>" http ://www.quora.com/xxxxxxx "、"タイプ"=>"quora"、"ユーザー名"=>"xxxxxx"、"type_id"=>"quora", "type_name"=>"Quora"}, {"url"=>" http://twitter.com/xxxxxxx ", "type"=>"twitter", "username"=> "xxxxx", "type_id"=>"twitter", "フォロワー" => "1000" "type_name"=>"Twitter"}, {"url"=>" http://plancast.com/user/xxxxxx=>" http://plancast.com/user/xxxxxx=>" http://plancast.com/user/xxxxxx", "id"=>"xxxxxx", "type"=>"plancast", "type_id"=>"plancast", "type_name"=>"Plancast"}, {"url"=>" http:// youtube.com/user/xxxxxxx ", "type"=>"youtube", "username"=>"xxxxxx", "type_id"=>"youtube", "type_name"=>"Youtube"}]
ありがとう!