title: My instances aren't saving for some reason in Ruby
body: <p>I posted a similar question to the same problem. I am trying to return an array of all instances initialized from an API. I have a cli, and api, and custom class that handles initialization. I have used binding.pry to look at what is going on before i request to see my array (it would return nothing when it hit in my cli), and it shows up empty. I guess what I am trying to say is that I can't figure out why they aren't saving.
  [my cli][1]</p>
  <p>class Cli</p>
  <pre><code>def run
      puts &quot;Welcome to the I'm Bored app!&quot;
      api = Api.new()
      input = nil
      while input != &quot;exit&quot;
          puts &quot;How would you like to generate your event?&quot;
          puts &quot;You can generate by type, number of participants, or random!&quot;
          puts &quot;Types include education, recreational, social, diy, charity, cooking, relaxation, music, or busywork.&quot;
          puts &quot;Participants can range from 0-5 number you like.&quot;
          puts &quot;To generate a totally random event, type 'random'&quot;
          puts &quot;To see all events made so far, type 'events'.&quot;
          puts &quot;To quit, type 'exit'.&quot;
          # puts &quot;How would you like to generate your event?&quot;
              input = gets.strip.downcase
  
              if input == &quot;type&quot;
              puts
              puts &quot;Please select education, recreational, social, diy, charity, cooking, relaxation, music, or busywork.&quot;
              input = gets.strip.downcase
              puts
              api.event_by_type(input)
              puts
              end
          
  
              if input == &quot;participants&quot;
              puts
              puts &quot;Please enter your number of participants.&quot;
              input = gets.strip.downcase
              puts
              api.event_by_participants(input)
              puts
              end
  
              if input == &quot;random&quot;
              puts
              puts &quot;Let's roll those dice!&quot;
              puts
              api.event_by_random(&quot;activity&quot;)
              puts
              end
  
              if input == &quot;events&quot;
              puts
              puts &quot;Here are your created events&quot;
              puts
              #binding.pry
              Api.each do |key,value|       # map would work just as well, but not needed
                  my_hash[key] = some_new_value    
                end
              # puts Api.all.each do |hash| 
              #     #hash.each do |key,value| 
              #       puts hash.type #(key + ': ' + value) 
              #     #end
                end
              puts
              # end
              # Api.all.map
              end
              
            if input == &quot;exit&quot;
              puts
              puts &quot;Take care!&quot;
              puts
              exit
          end     
  
          # if input != &quot;types&quot; &amp;&amp; != &quot;participants&quot; &amp;&amp; != &quot;random&quot; &amp;&amp; != &quot;events&quot; &amp;&amp; != &quot;exit&quot;
          #     input = gets.strip.downcase
          #     puts &quot;I think you mispelled something. Try again.&quot;
          #     puts
          # end
      end
  end
  </code></pre>
  <p>[my api][2]</p>
  <pre><code>class Api
  attr_accessor :url
  
  @@all = []
  
  
  def initialize()
      @url = &quot;http://www.boredapi.com/api/&quot; #does not work for some reason. returns empty. works fine with test in im-bored.???
  end
  
   def self.all
       @@all
   end
  
  def event_by_random(random)
      # http://www.boredapi.com/api/activity/
      req_url=&quot;#{@url}#{random}/&quot;
      # 'puts req_url' # Test to make sure I still get the right URL
      data = HTTParty.get(req_url) 
      @@all &lt;&lt; data
      puts data
  end
  
  def event_by_type(type)
      # http://www.boredapi.com/api/activity/
      req_url=&quot;#{@url}activity?type=#{type}&quot;
      puts req_url # Test to make sure I still get the right URL
      data = HTTParty.get(req_url) 
      puts data
  end
  
  def event_by_participants(participants)
      # http://www.boredapi.com/api/activity/
      req_url=&quot;#{@url}activity?participants=#{participants}&quot;
      # puts req_url # Test to make sure I still get the right URL
      data = HTTParty.get(req_url) 
      puts data
  end
  </code></pre>
  <p>end</p>
  <p>[my custom ][3]</p>
  <pre><code>class Suggestion
   attr_accessor :type, :participants 
  # attr_reader :activity, :price, :link, :key, :accessibility
  @@all = []
  
    def initialize(type, participants)
        @type = type
        @participants = participants
        @@all &lt;&lt; self
    end 
  
    def self.all
        @@all
    end 
  end
  </code></pre>