How to call instance variables in ruby
<p>I have recently learned how to create classes, although I am not <em>ENTIRELY</em> sure where and why I should use them.
I'd use them to create objects, which have similar methods/properties.</p>

<p>I tried making a gag code, but I stumbled upon a question I can't find an answer to.</p>

<pre><code>class Person
  def initialize(name,health)
    @name = name
    @hp = health
  end

  def kick
    @hp -= 1
    if (@hp &lt;= 0)
      puts "#{@name} got REKT!"
    end
  end

end

#Friends
michael = Person.new("Michael", 10)

10.times { michael.kick }
</code></pre>

<p>Even though this code works, I'm wondering if it is possible to use/call mihchael's hp outside the class? Perhaps sort of like a hash? <code>michael[@hp]</code>? But this doesn't work, even if i set hp to be a global variable.
Should all if/else statements who check object's properties be inside the class?</p>

<p>Thank you very much</p>