From: findchris@... Date: 2014-12-12T22:25:32+00:00 Subject: [ruby-core:66817] [ruby-trunk - Bug #10594] Numeric#clamp Issue #10594 has been updated by Chris Johnson. Example behavior: ~~~ 234234234523.clamp(0..100) # => 100 12.clamp(0..100) # => 12 -38817112.clamp(0..100) # => 0 ~~~ ---------------------------------------- Bug #10594: Numeric#clamp https://bugs.ruby-lang.org/issues/10594#change-50386 * Author: Chris Johnson * Status: Open * Priority: Normal * Assignee: * Category: core * Target version: * ruby -v: 2.1.2 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- This is basically a re-opening of the feature request of issue#4573 (https://bugs.ruby-lang.org/issues/4574), which was closed due a naming debate. It seems the standard naming for restricting a number to a specified range is indeed 'clamp'. (1)(2)(3) As such, can we use Yusuke Endoh's original patch with the naming adjustments? If so, I can provide accordingly. Cheers. (1) http://www.rubydoc.info/github/epitron/epitools/Numeric:clamp (2) http://stackoverflow.com/questions/12020787/is-there-a-limit-clamp-function-in-ruby (3) https://developer.gnome.org/glib/stable/glib-Standard-Macros.html#CLAMP:CAPS -- https://bugs.ruby-lang.org/