Module Comparable
In: lib/facets/core/comparable/cmp.rb
lib/facets/core/comparable/at_least.rb
lib/facets/core/comparable/clip.rb

Methods

at_least   at_most   cap   clip   cmp  

Public Instance methods

Returns the lower of self or x.

  4.at_least(5)  #=> 5
  6.at_least(5)  #=> 6

Returns the greater of self or x.

  4.at_most(5)  #=> 4
  6.at_most(5)  #=> 5

Returns the greater of self or x.

  4.cap(5)  #=> 4
  6.cap(5)  #=> 5

Returns self if above the given lower bound, or within the given lower and upper bounds, otherwise returns the the bound of which the value falls outside.

  4.clip(3)    #=> 4
  4.clip(5)    #=> 5
  4.clip(2,7)  #=> 4
  9.clip(2,7)  #=> 7
  1.clip(2,7)  #=> 2

Alternate name for comparison operator #<=>.

  3.cmp(1)   #=>  1
  3.cmp(3)   #=>  0
  3.cmp(10)  #=> -1

[Validate]