Sha256: 4c9c83ab1ea54edfb92c5e97beead4cc62bff195653ab0d95a44afe0adff1d67

Contents?: true

Size: 540 Bytes

Versions: 5

Compression:

Stored size: 540 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

5 entries across 5 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/comparable/cap.rb
facets-3.1.0 lib/core/facets/comparable/cap.rb
facets-3.0.0 lib/core/facets/comparable/cap.rb
facets-2.9.3 lib/core/facets/comparable/cap.rb
facets-2.9.2 lib/core/facets/comparable/cap.rb