Skip to content

Instantly share code, notes, and snippets.

@austinbv
Created June 7, 2012 03:54
Show Gist options
  • Select an option

  • Save austinbv/2886469 to your computer and use it in GitHub Desktop.

Select an option

Save austinbv/2886469 to your computer and use it in GitHub Desktop.
class Fixnum
def clamp(range)
return range.include?(self) ? self : self > range.max ? range.max : range.min
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment