One of the most common suggestions when it comes to writing is to omit needless words, and it applies just as much to writing Ruby as writing stories.
There are two control structures to change here:
unlessblock:unless n.is_a? Integer return "n must be an integer." end
ifblock below the
unlessblock:if n <= 0 return "n must be greater than 0." end
Both blocks can be simplified using the zen of Ruby!
Refactor the code in the editor to use single-line