I have three Ruby files in the same directory:
classthree.rb
otherclass.rb
samplecode.rb
Here are the contents of classthree.rb:
require './samplecode.rb'
require './otherclass.rb'
class ClassThree
  def initialize()
    puts "this class three here"
  end
end
Here are the contents of samplecode.rb:
require './otherclass.rb'
require './classthree.rb'
class SampleCode
  $smart = SampleCode.new
  @sides = 3
  @@x = "333"
  def ugly()
    g = ClassThree.new
    puts g
    puts "monkey see"
  end
  def self.ugly()
    s = SampleCode.new
    s.ugly
    puts s
    puts $smart
    puts "monkey see this self"
  end
  SampleCode.ugly
end
Here are the contents of otherclass.rb:
require './samplecode.rb'
require './classthree.rb'
END {
  puts "ending"
}
BEGIN{
  puts "beginning"
}
class OtherClass
  def initialize()
    s = SampleCode.new
    s.ugly
  end
end
My two questions are:
- There has to be a better way than require './xyz.rb'for every class in the directory. Isn't there something like require './*.rb'?
- When I run ruby otherclass.rbI get the following output:

Why do I get "beginning" and "ending" twice each??
 
     
    