Sha256: 32188ba22a0dbc60b63aad1a35c2e48b8379831439f4464dad309e68a434f93f
Contents?: true
Size: 856 Bytes
Versions: 26
Compression:
Stored size: 856 Bytes
Contents
#-- # Credit goes to Florian Gross. #++ module Comparable # Returns the lower of self or x. # # 4.at_least(5) #=> 5 # 6.at_least(5) #=> 6 # def at_least(x) (self >= x) ? self : x end # Returns the greater of self or x. # # 4.at_most(5) #=> 4 # 6.at_most(5) #=> 5 # def at_most(x) (self <= x) ? self : x end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCComparable < Test::Unit::TestCase def test_at_most assert_equal( 3, 3.at_most(4) ) assert_equal( 4, 4.at_most(4) ) assert_equal( 4, 5.at_most(4) ) end def test_at_least assert_equal( 4, 3.at_least(4) ) assert_equal( 4, 4.at_least(4) ) assert_equal( 5, 5.at_least(4) ) end end =end
Version data entries
26 entries across 26 versions & 1 rubygems