This is simpler; just choose an instance variable name which is highly
unlikely to clash with anything else.
Of course, each instance of this object will have its own counter then.
If that’s not what you want, I’d use an instance variable within the
class itself.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.