module Angles
  BASES = { => 360,  => 400,  => 6400,  => Math::PI*2 , => 24 }

  def self.method_missing(meth, angle)
    from, to = BASES.values_at(*meth.to_s.split())
    raise NoMethodError, meth if (from.nil? or to.nil?)
    mod = (angle.to_f * to / from) % to
    angle < 0? mod - to: mod
  end

end


names = Angles::BASES.keys
puts  + *names.size % names
test = [-2, -1, 0, 1, 2*Math::PI, 16, 360/(2*Math::PI), 360-1, 400-1, 6400-1, 1_000_000]

test.each do |n|
  names.each do |first|
    res = names.map{|last| Angles.send((first +  + last).to_sym, n)}
    puts first + *names.size % res
  end
  puts
end