You can refine your class with
module RefinedString
refine String do
def to_boolean(text)
!!(text =~ /^(true|t|yes|y|1)$/i)
end
end
end
but how to refine module method? This:
module RefinedMath
refine Math do
def PI
22/7
end
end
end
raises: TypeError: wrong argument type Module (expected Class)
This piece of code will work:
Explanation:
Defining a module #method is equivalent to defining an instance method on its #singleton_class.