Sha256: 259855ea2f77daa2496c474b33c6ca564dabf39a4d1a093fdf1abf7f7324ce16

Contents?: true

Size: 539 Bytes

Versions: 15

Compression:

Stored size: 539 Bytes

Contents

module Comparable

  # Returns the lower of self or x.
  #
  #   4.at_least(5)  #=> 5
  #   6.at_least(5)  #=> 6
  #
  # CREDIT: Florian Gross

  def at_least(lower)
    (self >= lower) ? self : lower
  end

  # Returns the greater of self or x.
  #
  #   4.at_most(5)  #=> 4
  #   6.at_most(5)  #=> 5
  #
  # CREDIT: Florian Gross

  def at_most(upper)
    (self <= upper) ? self : upper
  end

  # Returns the greater of self or x.
  #
  #   4.cap(5)  #=> 4
  #   6.cap(5)  #=> 5
  #
  # CREDIT: Trans

  alias_method :cap, :at_most

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
facets-2.9.2 src/core/facets/comparable/cap.rb
facets-2.9.1 lib/core/facets/comparable/cap.rb
facets-2.9.0 lib/core/facets/comparable/cap.rb
facets-2.9.0.pre.2 lib/core/facets/comparable/cap.rb
facets-2.9.0.pre.1 lib/core/facets/comparable/cap.rb
facets-2.8.4 lib/core/facets/comparable/cap.rb
facets-2.8.3 lib/core/facets/comparable/cap.rb
facets-2.8.2 lib/core/facets/comparable/cap.rb
facets-2.8.1 lib/core/facets/comparable/cap.rb
facets-2.8.0 lib/core/facets/comparable/cap.rb
facets-2.7.0 lib/core/facets/comparable/cap.rb
facets-2.6.0 lib/core/facets/comparable/cap.rb
facets-2.5.0 lib/core/facets/comparable/cap.rb
facets-2.5.1 lib/core/facets/comparable/cap.rb
facets-2.5.2 lib/core/facets/comparable/cap.rb