You probably want to create a file called "mymath.rb" in the lib / directory and a Math patch, like this:
require 'mathn'
module Math
def self.to_rad angle
angle/180 * Math::PI
end
end
or you can do what @MBO said in your comment. The link seems inaccessible, but the Google archives give this little small suggestion that indicates a solution that may be cleaner than mine (although I prefer to keep the math material inside math):
The simplest solution is to define a conversion method in Numeric that converts the number of degrees to radians.
, Ruby 2.0 "Refinement", . ( :
module RadiansConversion
refine Math do
def to_rad angle
angle/180 * Math::PI
end
end
end
... - .
module MyApp
using RadiansConversion
p Math.to_rad 180
p Math.to_rad 235
end