# Let people know we're running puts "REQUIRED" # Add a new method on Object. This will add the methods # to All objects, regardless where we 'require' this. class Object def new_method self.class end end # Def a method on 'self', which will be the class whose # definition we require this inside of. def other_method "Not so new" end # The important point is that 'required' code works the same as the rest # of Ruby, with respect to the scope in which it executes - self here # is 'main' (the toplevel). puts "In 'requireme', self is #{self.inspect}"