When I put a method that refers to a pulled in package inside another method it leaves scope and fails.
What is the proper way to do this. I tried playing with the \'se
The mistake in the code is that @sandbox is an attribute of the class. The value would be initialized when an object of the class is created. Writing the initialization in the class will have no effect. @Maxim has explained this in his answer.
For the second code, when the interpreter runs through the code, it would execute it once. But that code cannot run more than once.
The code should be,
require 'package that has 'accounts''
class Name
    def initialize
      @sandbox = #working API connection
    end
    def get_account
        @sandbox.accounts do |resp|         #This is where error is
          resp.each do |account|
            if account.name == "John"
                name = account.name
            end
          end
        end
    end
end
new = Name.new
p new.get_account