Methods
Public Instance methods
at_least(x)

Returns the lower of self or x.

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

  CREDIT Florian Gross
# File lib/core/facets/comparable/bound.rb, line 16
  def at_least(x)
    (self >= x) ? self : x
  end
at_least(x)

Returns the lower of self or x.

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

  CREDIT Florian Gross
# File lib/core/facets/comparable/bound.rb, line 16
  def at_least(x)
    (self >= x) ? self : x
  end
at_most(x)

Returns the greater of self or x.

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

  CREDIT Florian Gross
# File lib/core/facets/comparable/bound.rb, line 27
  def at_most(x)
    (self <= x) ? self : x
  end
at_most(x)

Returns the greater of self or x.

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

  CREDIT Florian Gross
# File lib/core/facets/comparable/bound.rb, line 27
  def at_most(x)
    (self <= x) ? self : x
  end
bound(lower, upper=nil)

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

  CREDIT Trans
This method is also aliased as clip clip
# File lib/core/facets/comparable/bound.rb, line 55
  def bound(lower, upper=nil)
    return lower if self < lower
    return self unless upper
    return upper if self > upper
    return self
  end
bound(lower, upper=nil)

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

  CREDIT Trans
# File lib/core/facets/comparable/bound.rb, line 55
  def bound(lower, upper=nil)
    return lower if self < lower
    return self unless upper
    return upper if self > upper
    return self
  end
cap(upper)

Returns the greater of self or x.

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

  CREDIT Trans
# File lib/core/facets/comparable/bound.rb, line 38
  def cap(upper)
    (self <= upper) ? self : upper
  end
cap(upper)

Returns the greater of self or x.

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

  CREDIT Trans
# File lib/core/facets/comparable/bound.rb, line 38
  def cap(upper)
    (self <= upper) ? self : upper
  end
clip(lower, upper=nil)

Alias for bound

clip(lower, upper=nil)

Alias for bound

cmp(o)

Alternate name for comparison operator #<=>.

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

This fundamental compare method is used to keep comparison compatible with succ.

  CREDIT Peter Vanbroekhoven
# File lib/core/facets/comparable/cmp.rb, line 14
  def cmp(o)
    self<=>o
  end
cmp(o)

Alternate name for comparison operator #<=>.

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

This fundamental compare method is used to keep comparison compatible with succ.

  CREDIT Peter Vanbroekhoven
# File lib/core/facets/comparable/cmp.rb, line 14
  def cmp(o)
    self<=>o
  end