Ruby: Avoid assigning return value of methods to local variables of the same name
From the "Programming Ruby Book":
Assignment to a variable works as you would expect: the variable is simply set to the specified value. The only wrinkle has to do with variable declaration and an ambiguity between local variable names and method names. Ruby has no syntax to explicitly declare a variable: variables simply come into existence when they are assigned. Also, local variable names and method names look the same—there is no prefix like $ to d...
Declare private accessors in Ruby
Sometimes you might want certain accessors to only be available within your class, so you make them private. However Ruby will yell a warning at you if you do something like this:
private
attr_accessor :name
#=> warning: private attribute?
In order to filter out this noise you can declare your own accessor like so:
module PrivateAccessors
  def private_attr_accessor(*names)
    attr_accessor *names
    private *names
  end
  
  def private_attr_reader(*names)
    attr_reader *names
    private *names
  end
 
  def priva...